Skip to content

Commit cb0bc77

Browse files
authored
[Auth] Remove unnecessary throws on internal methods (#14154)
1 parent 653ab45 commit cb0bc77

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

FirebaseAuth/Sources/Swift/Storage/AuthUserDefaults.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class AuthUserDefaults {
3535
storage = UserDefaults()
3636
}
3737

38-
func data(forKey key: String) throws -> Data? {
38+
func data(forKey key: String) -> Data? {
3939
guard let allData = storage.persistentDomain(forName: persistentDomainName)
4040
else { return nil }
4141
if let data = allData[key] as? Data {
@@ -44,13 +44,13 @@ class AuthUserDefaults {
4444
return nil
4545
}
4646

47-
func setData(_ data: Data, forKey key: String) throws {
47+
func setData(_ data: Data, forKey key: String) {
4848
var allData = storage.persistentDomain(forName: persistentDomainName) ?? [:]
4949
allData[key] = data
5050
storage.setPersistentDomain(allData, forName: persistentDomainName)
5151
}
5252

53-
func removeData(forKey key: String) throws {
53+
func removeData(forKey key: String) {
5454
guard var allData = storage.persistentDomain(forName: persistentDomainName) else { return }
5555
allData.removeValue(forKey: key)
5656
storage.setPersistentDomain(allData, forName: persistentDomainName)

FirebaseAuth/Sources/Swift/SystemService/AuthStoredUserManager.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class AuthStoredUserManager {
4343
/// Get the user access group stored locally.
4444
/// - Returns: The stored user access group; otherwise, `nil`.
4545
func getStoredUserAccessGroup() -> String? {
46-
if let data = try? userDefaults.data(forKey: Self.storedUserAccessGroupKey) {
46+
if let data = userDefaults.data(forKey: Self.storedUserAccessGroupKey) {
4747
let userAccessGroup = String(data: data, encoding: .utf8)
4848
return userAccessGroup
4949
} else {
@@ -55,9 +55,9 @@ class AuthStoredUserManager {
5555
/// - Parameter accessGroup: The access group to be store.
5656
func setStoredUserAccessGroup(accessGroup: String?) {
5757
if let data = accessGroup?.data(using: .utf8) {
58-
try? userDefaults.setData(data, forKey: Self.storedUserAccessGroupKey)
58+
userDefaults.setData(data, forKey: Self.storedUserAccessGroupKey)
5959
} else {
60-
try? userDefaults.removeData(forKey: Self.storedUserAccessGroupKey)
60+
userDefaults.removeData(forKey: Self.storedUserAccessGroupKey)
6161
}
6262
}
6363

FirebaseAuth/Tests/Unit/AuthUserDefaultsTests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ class AuthUserDefaultsTests: XCTestCase {
3232
@brief Tests reading non-existing storage item.
3333
*/
3434
func testReadNonexisting() throws {
35-
XCTAssertNil(try storage.data(forKey: kKey))
35+
XCTAssertNil(storage.data(forKey: kKey))
3636
}
3737

3838
/** @fn testWriteRead
3939
@brief Tests writing and reading a storage item.
4040
*/
4141
func testWriteRead() throws {
4242
try storage.setData(dataFromString(kData), forKey: kKey)
43-
XCTAssertEqual(try storage.data(forKey: kKey), try dataFromString(kData))
43+
XCTAssertEqual(storage.data(forKey: kKey), try dataFromString(kData))
4444
}
4545

4646
/** @fn testOverwrite
@@ -50,7 +50,7 @@ class AuthUserDefaultsTests: XCTestCase {
5050
let kOtherData = "OTHER_DATA"
5151
try storage.setData(dataFromString(kData), forKey: kKey)
5252
try storage.setData(dataFromString(kOtherData), forKey: kKey)
53-
XCTAssertEqual(try storage.data(forKey: kKey), try dataFromString(kOtherData))
53+
XCTAssertEqual(storage.data(forKey: kKey), try dataFromString(kOtherData))
5454
}
5555

5656
/** @fn testRemove
@@ -67,7 +67,7 @@ class AuthUserDefaultsTests: XCTestCase {
6767
func testServices() throws {
6868
try storage.setData(dataFromString(kData), forKey: kKey)
6969
storage = AuthUserDefaults(service: "Other service")
70-
XCTAssertNil(try storage.data(forKey: kKey))
70+
XCTAssertNil(storage.data(forKey: kKey))
7171
}
7272

7373
/** @fn testStandardUserDefaults

0 commit comments

Comments
 (0)