-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adding error display feature (#436)
* feat: adding error display feature * feat: complete adding error display feature * refactor: handle error globally * refactor: minor change * refactor: update error handling method * refactor: format files * refactor: format files * refactor: remove files * rollback modifications on out of scope files * feat(wallet_kit): remove hardcoded 'Failed to add account" in wallet kit default error handler --------- Co-authored-by: Patrice Tisserand <[email protected]>
- Loading branch information
1 parent
b071ad1
commit d11675e
Showing
5 changed files
with
67 additions
and
25 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export 'wallet_kit_error.dart'; |
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,32 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
class WalletKitErrorHandler { | ||
static final WalletKitErrorHandler _instance = | ||
WalletKitErrorHandler._internal(); | ||
|
||
WalletKitErrorHandler._internal(); | ||
|
||
factory WalletKitErrorHandler() => _instance; | ||
|
||
void handleError( | ||
BuildContext context, | ||
WalletKitError error, | ||
String? message, | ||
) { | ||
ScaffoldMessenger.of(context).showSnackBar( | ||
SnackBar(content: Text('${message ?? "error"}: $error')), | ||
); | ||
Navigator.of(context).pop(); | ||
} | ||
} | ||
|
||
class WalletKitError implements Exception { | ||
final String message; | ||
final int? code; | ||
|
||
WalletKitError(this.message, {this.code}); | ||
|
||
@override | ||
String toString() => | ||
'WalletKitError: $message${code != null ? ' (Code: $code)' : ''}'; | ||
} |
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