-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: handle trustmark QR code generation failures
- Loading branch information
Showing
10 changed files
with
87 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { ErrorActorEvent } from "xstate"; | ||
|
||
export type TrustmarkEvents = ErrorActorEvent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { Errors } from "@pagopa/io-react-native-wallet"; | ||
import { TrustmarkEvents } from "./events"; | ||
|
||
const { isWalletProviderResponseError } = Errors; | ||
|
||
export enum TrustmarkFailureType { | ||
UNEXPECTED = "UNEXPECTED", | ||
WALLET_PROVIDER_GENERIC = "WALLET_PROVIDER_GENERIC" | ||
} | ||
|
||
export type TrustmarkFailure = { | ||
type: TrustmarkFailureType; | ||
reason: unknown; | ||
}; | ||
|
||
export const mapEventToFailure = (event: TrustmarkEvents): TrustmarkFailure => { | ||
if (!("error" in event)) { | ||
return { | ||
type: TrustmarkFailureType.UNEXPECTED, | ||
reason: event | ||
}; | ||
} | ||
|
||
const { error } = event; | ||
|
||
if (isWalletProviderResponseError(error)) { | ||
return { | ||
type: TrustmarkFailureType.WALLET_PROVIDER_GENERIC, | ||
reason: String(error) | ||
}; | ||
} | ||
|
||
return { | ||
type: TrustmarkFailureType.UNEXPECTED, | ||
reason: String(error) | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters