Skip to content

Commit

Permalink
chore(): updated native code error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
tyllark committed Feb 3, 2025
1 parent a7489f0 commit 859793c
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ class NativeAuthPluginWrapper(
userPoolTokens
)
onSuccess.accept(authSession)
} else {
AuthSessionResult.failure(couldNotFetchException)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/amplify_datastore/ios/Classes/CognitoPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class CognitoPlugin: AuthCategoryPlugin {
let returning = NativeAWSAuthCognitoSession(from: session)
continuation.resume(returning: returning)
case .failure(let error):
break //NoOp
continuation.resume(throwing: error)
}
}
}
Expand Down
18 changes: 14 additions & 4 deletions packages/amplify_datastore/ios/Classes/FlutterApiPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ public class FlutterApiPlugin: APICategoryPlugin, AWSAPIAuthInformation
if !reachabilityUpdate.isOnline {
DispatchQueue.main.async {
self.nativeApiPlugin.deviceOffline { result in
//NoOp
switch result {
case .success(let session):
break //NoOp
case .failure(let error):
throw error
}
}
}
}
Expand Down Expand Up @@ -97,7 +102,12 @@ public class FlutterApiPlugin: APICategoryPlugin, AWSAPIAuthInformation
if let subscriptionId {
DispatchQueue.main.async {
self.nativeApiPlugin.unsubscribe(subscriptionId: subscriptionId) { result in
//NoOp
switch result {
case .success(let session):
break //NoOp
case .failure(let error):
throw error
}
}
}
}
Expand Down Expand Up @@ -163,7 +173,7 @@ public class FlutterApiPlugin: APICategoryPlugin, AWSAPIAuthInformation
case .success(let response):
subscriptionId = response.subscriptionId
case .failure(let error):
break //NoOp
throw error
}
}
}
Expand Down Expand Up @@ -230,7 +240,7 @@ public class FlutterApiPlugin: APICategoryPlugin, AWSAPIAuthInformation
case .success(let response):
continuation.resume(returning: response)
case .failure(let error):
break //NoOp
throw error
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,12 @@ public class SwiftAmplifyDataStorePlugin: NSObject, FlutterPlugin, NativeAmplify
onStop(flutterResult: result)
DispatchQueue.main.async {
self.nativeApiPlugin.onStop { result in
//NoOp
switch result {
case .success(let session):
break //NoOp
case .failure(let error):
throw error
}
}
}
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,13 @@ class FlutterAuthProviders: APIAuthProviderFactory {
))
}
case .failure(let error):
break //NoOp
token = .failure(APIError.operationError(
"Unable to retrieve token for \(type)",
"""
Make sure you register your auth providers in the addPlugin call and \
that getLatestAuthToken returns a value.
"""
))
}
}
}
Expand Down

0 comments on commit 859793c

Please sign in to comment.