-
Notifications
You must be signed in to change notification settings - Fork 191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Auth] Handle errors #449
[Auth] Handle errors #449
Conversation
2d59141
to
0396e44
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not convinced about errors separation but for now have no suggestions, maybe let's discuss it?
Sources/Auth/AuthClient.swift
Outdated
@@ -87,9 +87,9 @@ public class AuthClient { | |||
try await appRequestService.request(params: params, topic: topic) | |||
} | |||
|
|||
public func respond(_ result: Result<RespondParams, ErrorCode>) async throws { | |||
public func respond(requestId: RPCID, result: Result<CacaoSignature, ExternalError>) async throws { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think here it should be a protocol error as well, as it is send to a peer
}.store(in: &publishers) | ||
} | ||
|
||
private func respondError(_ error: InternalError, topic: String, requestId: RPCID) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would it make sense if this method is async?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is no async context. I think it will be the same
@@ -0,0 +1,22 @@ | |||
import Foundation | |||
|
|||
public enum ExternalError: Codable, Equatable, Error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe PeerError?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My suggestion: ExternalError - errors which comes from outside. InternalError - errors which could occur during SDK execution
Sources/Auth/AuthClient.swift
Outdated
private var authResponsePublisherSubject = PassthroughSubject<(id: RPCID, result: Result<Cacao, ErrorCode>), Never>() | ||
public var authResponsePublisher: AnyPublisher<(id: RPCID, result: Result<Cacao, ErrorCode>), Never> { | ||
private var authResponsePublisherSubject = PassthroughSubject<(id: RPCID, result: Result<Cacao, InternalError>), Never>() | ||
public var authResponsePublisher: AnyPublisher<(id: RPCID, result: Result<Cacao, InternalError>), Never> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the error can be a protocol error.
consider case when wallet rejects a request - user initiated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so if it can be InternalError and ExternalError maybe we could have only one public error like: AuthError?
Description
Resolves #445
How Has This Been Tested?
Run integration and Auth unit tests
Due Dilligence