-
Notifications
You must be signed in to change notification settings - Fork 180
[SELF-662] feat: add mobile sdk error classes #916
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
Merged
transphorm
merged 4 commits into
dev
from
codex/work-on-3rd-architecture-checklist-task
Aug 19, 2025
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,11 @@ | ||
| # Error Classes | ||
|
|
||
| | Error Class | Category | Code | Description | | ||
| | --------------- | ------------ | -------------------- | ------------------------------------------------------------ | | ||
| | `NfcParseError` | `validation` | `SELF_ERR_NFC_PARSE` | Thrown when NFC byte streams are malformed or decoding fails | | ||
| | `MrzParseError` | `validation` | `SELF_ERR_MRZ_PARSE` | Raised for invalid MRZ characters or formats | | ||
| | `InitError` | `init` | `SELF_ERR_INIT` | Issues during SDK initialization | | ||
| | `LivenessError` | `liveness` | `SELF_ERR_LIVENESS` | Errors from liveness checks | | ||
| | `SdkError` | varies | custom | Base class for all SDK errors | | ||
|
|
||
| Use typed errors instead of generic `Error` to surface clearer failure modes and consistent categorization. |
This file contains hidden or 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,14 @@ | ||
| import { SdkError } from './SdkError'; | ||
|
|
||
| /** | ||
| * Error thrown when the SDK fails to initialize correctly. | ||
| * | ||
| * @param message - description of the initialization failure. | ||
| * @param options - optional underlying error details. | ||
| */ | ||
| export class InitError extends SdkError { | ||
| constructor(message: string, options?: { cause?: unknown }) { | ||
| super(message, 'SELF_ERR_INIT', 'init', false, options); | ||
| this.name = 'InitError'; | ||
transphorm marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
This file contains hidden or 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,14 @@ | ||
| import { SdkError } from './SdkError'; | ||
|
|
||
| /** | ||
| * Error thrown when liveness checks detect an issue. | ||
| * | ||
| * @param message - description of the liveness failure. | ||
| * @param options - optional underlying error details. | ||
| */ | ||
| export class LivenessError extends SdkError { | ||
| constructor(message: string, options?: { cause?: unknown }) { | ||
| super(message, 'SELF_ERR_LIVENESS', 'liveness', false, options); | ||
| this.name = 'LivenessError'; | ||
transphorm marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
This file contains hidden or 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,14 @@ | ||
| import { SdkError } from './SdkError'; | ||
|
|
||
| /** | ||
| * Error thrown when an MRZ string fails validation or parsing. | ||
| * | ||
| * @param message - description of the MRZ parsing failure. | ||
| * @param options - optional underlying error details. | ||
| */ | ||
| export class MrzParseError extends SdkError { | ||
| constructor(message: string, options?: { cause?: unknown }) { | ||
| super(message, 'SELF_ERR_MRZ_PARSE', 'validation', false, options); | ||
| this.name = 'MrzParseError'; | ||
transphorm marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
This file contains hidden or 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,14 @@ | ||
| import { SdkError } from './SdkError'; | ||
|
|
||
| /** | ||
| * Error thrown when NFC data cannot be parsed. | ||
| * | ||
| * @param message - description of the parsing failure. | ||
| * @param options - optional underlying error details. | ||
| */ | ||
| export class NfcParseError extends SdkError { | ||
| constructor(message: string, options?: { cause?: unknown }) { | ||
| super(message, 'SELF_ERR_NFC_PARSE', 'validation', false, options); | ||
| this.name = 'NfcParseError'; | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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,12 @@ | ||
| export { InitError } from './InitError'; | ||
|
|
||
| export { LivenessError } from './LivenessError'; | ||
| export { MrzParseError } from './MrzParseError'; | ||
| export { NfcParseError } from './NfcParseError'; | ||
| export const SCANNER_ERROR_CODES = { | ||
| UNAVAILABLE: 'SELF_ERR_SCANNER_UNAVAILABLE', | ||
| NFC_NOT_SUPPORTED: 'SELF_ERR_NFC_NOT_SUPPORTED', | ||
| INVALID_MODE: 'SELF_ERR_SCANNER_MODE', | ||
| } as const; | ||
|
|
||
| export { SdkError, type SdkErrorCategory, notImplemented, sdkError } from './SdkError'; |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.