Skip to content
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

Merged
merged 7 commits into from
Aug 22, 2022
Merged

[Auth] Handle errors #449

merged 7 commits into from
Aug 22, 2022

Conversation

flypaper0
Copy link
Contributor

@flypaper0 flypaper0 commented Aug 18, 2022

Description

  • App / Wallet subscribers error handling
  • InternalError and ExternalError implemented
  • WalletRespondService respond with error

Resolves #445

How Has This Been Tested?

Run integration and Auth unit tests

Due Dilligence

@arein arein added the accepted label Aug 18, 2022
@flypaper0 flypaper0 force-pushed the feature/auth-handle-errors-#445 branch from 2d59141 to 0396e44 Compare August 19, 2022 11:46
@flypaper0 flypaper0 marked this pull request as ready for review August 19, 2022 12:10
Copy link
Contributor

@llbartekll llbartekll left a 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?

@@ -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 {
Copy link
Contributor

@llbartekll llbartekll Aug 19, 2022

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) {
Copy link
Contributor

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?

Copy link
Contributor Author

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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe PeerError?

Copy link
Contributor Author

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

Example/IntegrationTests/Auth/AuthTests.swift Outdated Show resolved Hide resolved
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> {
Copy link
Contributor

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

Copy link
Contributor

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?

@flypaper0 flypaper0 requested a review from llbartekll August 22, 2022 14:57
@flypaper0 flypaper0 merged commit e24ac11 into develop Aug 22, 2022
@flypaper0 flypaper0 deleted the feature/auth-handle-errors-#445 branch August 22, 2022 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants