-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from archethic-foundation/error_management
Error_management
- Loading branch information
Showing
11 changed files
with
625 additions
and
385 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
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 |
---|---|---|
@@ -1,18 +1,33 @@ | ||
part of '../wagmi.js.dart'; | ||
|
||
/// Generic JSError | ||
extension type JSError._(JSObject _) implements JSObject {} | ||
|
||
/// Generic indexed DB/Javascript error. | ||
extension JSErrorExt on JSError { | ||
@JS() | ||
extension type JSError._(JSObject _) implements JSObject { | ||
/// Get the error message | ||
external String? get message; | ||
|
||
/// Get the error message | ||
external String? get name; | ||
|
||
external JSArray<JSString>? get metaMessages; | ||
external JSString? get shortMessage; | ||
external JSString? get version; | ||
external JSError? get cause; | ||
external JSString? get docsPath; | ||
|
||
WagmiError get toDart => WagmiError( | ||
message: message, | ||
name: name, | ||
name: | ||
WagmiErrors.values.firstWhereOrNull((value) => value.name == name), | ||
metaMessages: metaMessages?.toDart | ||
.map( | ||
(message) => message.toDart, | ||
) | ||
.toList(), | ||
shortMessage: shortMessage?.toDart, | ||
version: version?.toDart, | ||
cause: cause?.toDart, | ||
docsPath: docsPath?.toDart, | ||
details: toMap(), | ||
); | ||
} |
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 |
---|---|---|
@@ -1,12 +1,197 @@ | ||
// ignore_for_file: constant_identifier_names | ||
|
||
class WagmiError implements Exception { | ||
WagmiError({ | ||
this.message, | ||
this.name, | ||
this.message, | ||
this.metaMessages, | ||
this.shortMessage, | ||
this.version, | ||
this.cause, | ||
this.docsPath, | ||
this.details, | ||
}); | ||
|
||
final WagmiErrors? name; | ||
final String? message; | ||
final String? name; | ||
final List<String>? metaMessages; | ||
final String? shortMessage; | ||
final String? version; | ||
final WagmiError? cause; | ||
final String? docsPath; | ||
|
||
/// The raw error object | ||
final Map<String, dynamic>? details; | ||
|
||
/// Returns the first error or cause matching given type. | ||
WagmiError? findError(WagmiErrors errorName) { | ||
if (name == errorName) return this; | ||
|
||
if (cause == null) return null; | ||
|
||
return cause!.findError(errorName); | ||
} | ||
|
||
@override | ||
String toString() => '$name : $message'; | ||
String toString() => '$name : ${message ?? shortMessage}'; | ||
} | ||
|
||
enum WagmiErrors { | ||
/// [abi](https://github.com/wevm/viem/blob/main/src/errors/abi.ts) | ||
AbiConstructorNotFoundError, | ||
AbiConstructorParamsNotFoundError, | ||
AbiDecodingDataSizeInvalidError, | ||
AbiDecodingDataSizeTooSmallError, | ||
AbiDecodingZeroDataError, | ||
AbiEncodingArrayLengthMismatchError, | ||
AbiEncodingBytesSizeMismatchError, | ||
AbiEncodingLengthMismatchError, | ||
AbiErrorInputsNotFoundError, | ||
AbiErrorNotFoundError, | ||
AbiErrorSignatureNotFoundError, | ||
AbiEventSignatureEmptyTopicsError, | ||
AbiEventSignatureNotFoundError, | ||
AbiEventNotFoundError, | ||
AbiFunctionNotFoundError, | ||
AbiFunctionOutputsNotFoundError, | ||
AbiFunctionSignatureNotFoundError, | ||
AbiItemAmbiguityError, | ||
BytesSizeMismatchError, | ||
InvalidAbiEncodingTypeError, | ||
InvalidAbiDecodingTypeError, | ||
InvalidArrayError, | ||
InvalidDefinitionTypeError, | ||
|
||
/// [account](https://github.com/wevm/viem/blob/main/src/errors/account.ts) | ||
AccountNotFoundError, | ||
AccountTypeNotSupportedError, | ||
|
||
/// [address](https://github.com/wevm/viem/blob/main/src/errors/address.ts) | ||
InvalidAddressError, | ||
|
||
/// [blob](https://github.com/wevm/viem/blob/main/src/errors/blob.ts) | ||
BlobSizeTooLargeError, | ||
EmptyBlobError, | ||
InvalidVersionedHashSizeError, | ||
InvalidVersionedHashVersionError, | ||
|
||
/// [block](https://github.com/wevm/viem/blob/main/src/errors/block.ts) | ||
BlockNotFoundError, | ||
|
||
/// [ccip](https://github.com/wevm/viem/blob/main/src/errors/ccip.ts) | ||
OffchainLookupError, | ||
OffchainLookupResponseMalformedError, | ||
OffchainLookupSenderMismatchError, | ||
|
||
/// [chain](https://github.com/wevm/viem/blob/main/src/errors/chain.ts) | ||
ChainMismatchError, | ||
ChainNotFoundError, | ||
ClientChainNotConfiguredError, | ||
InvalidChainIdError, | ||
|
||
/// [contract](https://github.com/wevm/viem/blob/main/src/errors/contract.ts) | ||
CallExecutionError, | ||
ContractFunctionExecutionError, | ||
ContractFunctionRevertedError, | ||
ContractFunctionZeroDataError, | ||
CounterfactualDeploymentFailedError, | ||
RawContractError, | ||
|
||
/// [cursor](https://github.com/wevm/viem/blob/main/src/errors/cursor.ts) | ||
NegativeOffsetError, | ||
PositionOutOfBoundsError, | ||
RecursiveReadLimitExceededError, | ||
|
||
/// [data](https://github.com/wevm/viem/blob/main/src/errors/data.ts) | ||
SliceOffsetOutOfBoundsError, | ||
SizeExceedsPaddingSizeError, | ||
InvalidBytesLengthError, | ||
|
||
/// [encoding](https://github.com/wevm/viem/blob/main/src/errors/encoding.ts) | ||
IntegerOutOfRangeError, | ||
InvalidBytesBooleanError, | ||
InvalidHexBooleanError, | ||
InvalidHexValueError, | ||
SizeOverflowError, | ||
|
||
/// [ens](https://github.com/wevm/viem/blob/main/src/errors/ens.ts) | ||
EnsAvatarInvalidMetadataError, | ||
EnsAvatarInvalidNftUriError, | ||
EnsAvatarUriResolutionError, | ||
EnsAvatarUnsupportedNamespaceError, | ||
|
||
/// [estimateGas](https://github.com/wevm/viem/blob/main/src/errors/estimateGas.ts) | ||
EstimateGasExecutionError, | ||
|
||
/// [fee](https://github.com/wevm/viem/blob/main/src/errors/fee.ts) | ||
BaseFeeScalarError, | ||
MaxFeePerGasTooLowError, | ||
|
||
/// [log](https://github.com/wevm/viem/blob/main/src/errors/log.ts) | ||
FilterTypeNotSupportedError, | ||
|
||
/// [node](https://github.com/wevm/viem/blob/main/src/errors/node.ts) | ||
ExecutionRevertedError, | ||
FeeCapTooHighError, | ||
FeeCapTooLowError, | ||
NonceTooHighError, | ||
NonceTooLowError, | ||
NonceMaxValueError, | ||
InsufficientFundsError, | ||
IntrinsicGasTooHighError, | ||
IntrinsicGasTooLowError, | ||
TransactionTypeNotSupportedError, | ||
TipAboveFeeCapError, | ||
UnknownNodeError, | ||
|
||
/// [request](https://github.com/wevm/viem/blob/main/src/errors/request.ts) | ||
HttpRequestError, | ||
WebSocketRequestError, | ||
RpcRequestError, | ||
SocketClosedError, | ||
TimeoutError, | ||
|
||
/// [rpc](https://github.com/wevm/viem/blob/main/src/errors/rpc.ts) | ||
ProviderRpcError, | ||
ParseRpcError, | ||
InvalidRequestRpcError, | ||
MethodNotFoundRpcError, | ||
InvalidParamsRpcError, | ||
InternalRpcError, | ||
InvalidInputRpcError, | ||
ResourceNotFoundRpcError, | ||
ResourceUnavailableRpcError, | ||
TransactionRejectedRpcError, | ||
MethodNotSupportedRpcError, | ||
LimitExceededRpcError, | ||
JsonRpcVersionUnsupportedError, | ||
UserRejectedRequestError, | ||
UnauthorizedProviderError, | ||
UnsupportedProviderMethodError, | ||
ProviderDisconnectedError, | ||
ChainDisconnectedError, | ||
SwitchChainError, | ||
UnknownRpcError, | ||
|
||
/// [siwe](https://github.com/wevm/viem/blob/main/src/errors/siwe.ts) | ||
SiweInvalidMessageFieldError, | ||
|
||
/// [stateOverride](https://github.com/wevm/viem/blob/main/src/errors/stateOverride.ts) | ||
AccountStateConflictError, | ||
StateAssignmentConflictError, | ||
|
||
/// [transaction](https://github.com/wevm/viem/blob/main/src/errors/transaction.ts) | ||
FeeConflictError, | ||
InvalidLegacyVError, | ||
InvalidSerializableTransactionError, | ||
InvalidSerializedTransactionTypeError, | ||
InvalidSerializedTransactionError, | ||
InvalidStorageKeySizeError, | ||
TransactionExecutionError, | ||
TransactionNotFoundError, | ||
TransactionReceiptNotFoundError, | ||
WaitForTransactionReceiptTimeoutError, | ||
|
||
/// [transport](https://github.com/wevm/viem/blob/main/src/errors/transport.ts) | ||
UrlRequiredError, | ||
} |
Oops, something went wrong.