module Cometa.Error.Code
(
ErrorCode
( Success,
GenericFailure,
InsufficientBufferSize,
NullPointer,
MemoryAllocationFailed,
OutOfBoundsMemoryRead,
OutOfBoundsMemoryWrite,
InvalidArgument,
InvalidUrl,
ElementNotFound,
EncodingFailure,
DecodingFailure,
ChecksumMismatch,
InvalidJson,
IntegerOverflow,
IntegerUnderflow,
ConversionFailed,
IndexOutOfBounds,
InvalidCertificateType,
NotImplemented,
InvalidPassphrase,
IllegalState,
DuplicateKey,
JsonTypeMismatch,
LossOfPrecision,
InvalidMagic,
InvalidChecksum,
InvalidBlake2bHashSize,
InvalidEd25519SignatureSize,
InvalidEd25519PublicKeySize,
InvalidEd25519PrivateKeySize,
InvalidBip32PublicKeySize,
InvalidBip32PrivateKeySize,
InvalidBip32DerivationIndex,
UnexpectedCborType,
InvalidCborValue,
InvalidCborArraySize,
InvalidCborMapSize,
DuplicateCborMapKey,
InvalidCborMapKey,
InvalidAddressType,
InvalidAddressFormat,
InvalidCredentialType,
InvalidPlutusDataConversion,
InvalidDatumType,
InvalidScriptLanguage,
InvalidNativeScriptType,
InvalidPlutusCostModel,
InvalidProposalProcedureType,
InvalidMetadatumConversion,
InvalidMetadatumTextStringSize,
InvalidMetadatumBoundedBytesSize,
InvalidHttpRequest,
InsufficientBalance,
UtxoNotFragmentedEnough,
UtxoFullyDepleted,
MaximumInputCountExceeded,
UnbalancedSubTransactions,
DisallowedSupplementalDatums,
MissingRedeemer,
ScriptEvaluationFailure
),
fromNumber,
toNumber,
isKnown,
knownCodes,
)
where
data ErrorCode
=
Success
|
GenericFailure
|
InsufficientBufferSize
|
NullPointer
|
MemoryAllocationFailed
|
OutOfBoundsMemoryRead
|
OutOfBoundsMemoryWrite
|
InvalidArgument
|
InvalidUrl
|
ElementNotFound
|
EncodingFailure
|
DecodingFailure
|
ChecksumMismatch
|
InvalidJson
|
IntegerOverflow
|
IntegerUnderflow
|
ConversionFailed
|
IndexOutOfBounds
|
InvalidCertificateType
|
NotImplemented
|
InvalidPassphrase
|
IllegalState
|
DuplicateKey
|
JsonTypeMismatch
|
LossOfPrecision
|
InvalidMagic
|
InvalidChecksum
|
InvalidBlake2bHashSize
|
InvalidEd25519SignatureSize
|
InvalidEd25519PublicKeySize
|
InvalidEd25519PrivateKeySize
|
InvalidBip32PublicKeySize
|
InvalidBip32PrivateKeySize
|
InvalidBip32DerivationIndex
|
UnexpectedCborType
|
InvalidCborValue
|
InvalidCborArraySize
|
InvalidCborMapSize
|
DuplicateCborMapKey
|
InvalidCborMapKey
|
InvalidAddressType
|
InvalidAddressFormat
|
InvalidCredentialType
|
InvalidPlutusDataConversion
|
InvalidDatumType
|
InvalidScriptLanguage
|
InvalidNativeScriptType
|
InvalidPlutusCostModel
|
InvalidProposalProcedureType
|
InvalidMetadatumConversion
|
InvalidMetadatumTextStringSize
|
InvalidMetadatumBoundedBytesSize
|
InvalidHttpRequest
|
InsufficientBalance
|
UtxoNotFragmentedEnough
|
UtxoFullyDepleted
|
MaximumInputCountExceeded
|
UnbalancedSubTransactions
|
DisallowedSupplementalDatums
|
MissingRedeemer
|
ScriptEvaluationFailure
| UnknownCode !Integer
deriving (ErrorCode -> ErrorCode -> Bool
(ErrorCode -> ErrorCode -> Bool)
-> (ErrorCode -> ErrorCode -> Bool) -> Eq ErrorCode
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ErrorCode -> ErrorCode -> Bool
== :: ErrorCode -> ErrorCode -> Bool
$c/= :: ErrorCode -> ErrorCode -> Bool
/= :: ErrorCode -> ErrorCode -> Bool
Eq, Int -> ErrorCode -> ShowS
[ErrorCode] -> ShowS
ErrorCode -> String
(Int -> ErrorCode -> ShowS)
-> (ErrorCode -> String)
-> ([ErrorCode] -> ShowS)
-> Show ErrorCode
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ErrorCode -> ShowS
showsPrec :: Int -> ErrorCode -> ShowS
$cshow :: ErrorCode -> String
show :: ErrorCode -> String
$cshowList :: [ErrorCode] -> ShowS
showList :: [ErrorCode] -> ShowS
Show)
fromNumber :: Integer -> ErrorCode
fromNumber :: Integer -> ErrorCode
fromNumber Integer
number = case Integer -> [(Integer, ErrorCode)] -> Maybe ErrorCode
forall a b. Eq a => a -> [(a, b)] -> Maybe b
lookup Integer
number [(ErrorCode -> Integer
toNumber ErrorCode
code, ErrorCode
code) | ErrorCode
code <- [ErrorCode]
knownCodes] of
Just ErrorCode
code -> ErrorCode
code
Maybe ErrorCode
Nothing -> Integer -> ErrorCode
UnknownCode Integer
number
toNumber :: ErrorCode -> Integer
toNumber :: ErrorCode -> Integer
toNumber ErrorCode
code = case ErrorCode
code of
ErrorCode
Success -> Integer
0
ErrorCode
GenericFailure -> Integer
1
ErrorCode
InsufficientBufferSize -> Integer
2
ErrorCode
NullPointer -> Integer
3
ErrorCode
MemoryAllocationFailed -> Integer
4
ErrorCode
OutOfBoundsMemoryRead -> Integer
5
ErrorCode
OutOfBoundsMemoryWrite -> Integer
6
ErrorCode
InvalidArgument -> Integer
7
ErrorCode
InvalidUrl -> Integer
8
ErrorCode
ElementNotFound -> Integer
9
ErrorCode
EncodingFailure -> Integer
10
ErrorCode
DecodingFailure -> Integer
11
ErrorCode
ChecksumMismatch -> Integer
12
ErrorCode
InvalidJson -> Integer
13
ErrorCode
IntegerOverflow -> Integer
14
ErrorCode
IntegerUnderflow -> Integer
15
ErrorCode
ConversionFailed -> Integer
16
ErrorCode
IndexOutOfBounds -> Integer
17
ErrorCode
InvalidCertificateType -> Integer
18
ErrorCode
NotImplemented -> Integer
19
ErrorCode
InvalidPassphrase -> Integer
20
ErrorCode
IllegalState -> Integer
21
ErrorCode
DuplicateKey -> Integer
22
ErrorCode
JsonTypeMismatch -> Integer
23
ErrorCode
LossOfPrecision -> Integer
100
ErrorCode
InvalidMagic -> Integer
101
ErrorCode
InvalidChecksum -> Integer
102
ErrorCode
InvalidBlake2bHashSize -> Integer
200
ErrorCode
InvalidEd25519SignatureSize -> Integer
201
ErrorCode
InvalidEd25519PublicKeySize -> Integer
202
ErrorCode
InvalidEd25519PrivateKeySize -> Integer
203
ErrorCode
InvalidBip32PublicKeySize -> Integer
204
ErrorCode
InvalidBip32PrivateKeySize -> Integer
205
ErrorCode
InvalidBip32DerivationIndex -> Integer
206
ErrorCode
UnexpectedCborType -> Integer
300
ErrorCode
InvalidCborValue -> Integer
301
ErrorCode
InvalidCborArraySize -> Integer
302
ErrorCode
InvalidCborMapSize -> Integer
303
ErrorCode
DuplicateCborMapKey -> Integer
304
ErrorCode
InvalidCborMapKey -> Integer
305
ErrorCode
InvalidAddressType -> Integer
400
ErrorCode
InvalidAddressFormat -> Integer
401
ErrorCode
InvalidCredentialType -> Integer
500
ErrorCode
InvalidPlutusDataConversion -> Integer
600
ErrorCode
InvalidDatumType -> Integer
601
ErrorCode
InvalidScriptLanguage -> Integer
700
ErrorCode
InvalidNativeScriptType -> Integer
701
ErrorCode
InvalidPlutusCostModel -> Integer
702
ErrorCode
InvalidProposalProcedureType -> Integer
800
ErrorCode
InvalidMetadatumConversion -> Integer
900
ErrorCode
InvalidMetadatumTextStringSize -> Integer
901
ErrorCode
InvalidMetadatumBoundedBytesSize -> Integer
902
ErrorCode
InvalidHttpRequest -> Integer
1000
ErrorCode
InsufficientBalance -> Integer
1100
ErrorCode
UtxoNotFragmentedEnough -> Integer
1101
ErrorCode
UtxoFullyDepleted -> Integer
1102
ErrorCode
MaximumInputCountExceeded -> Integer
1103
ErrorCode
UnbalancedSubTransactions -> Integer
1104
ErrorCode
DisallowedSupplementalDatums -> Integer
1105
ErrorCode
MissingRedeemer -> Integer
1106
ErrorCode
ScriptEvaluationFailure -> Integer
1200
UnknownCode Integer
number -> Integer
number
isKnown :: ErrorCode -> Bool
isKnown :: ErrorCode -> Bool
isKnown (UnknownCode Integer
_) = Bool
False
isKnown ErrorCode
_ = Bool
True
knownCodes :: [ErrorCode]
knownCodes :: [ErrorCode]
knownCodes =
[ ErrorCode
Success,
ErrorCode
GenericFailure,
ErrorCode
InsufficientBufferSize,
ErrorCode
NullPointer,
ErrorCode
MemoryAllocationFailed,
ErrorCode
OutOfBoundsMemoryRead,
ErrorCode
OutOfBoundsMemoryWrite,
ErrorCode
InvalidArgument,
ErrorCode
InvalidUrl,
ErrorCode
ElementNotFound,
ErrorCode
EncodingFailure,
ErrorCode
DecodingFailure,
ErrorCode
ChecksumMismatch,
ErrorCode
InvalidJson,
ErrorCode
IntegerOverflow,
ErrorCode
IntegerUnderflow,
ErrorCode
ConversionFailed,
ErrorCode
IndexOutOfBounds,
ErrorCode
InvalidCertificateType,
ErrorCode
NotImplemented,
ErrorCode
InvalidPassphrase,
ErrorCode
IllegalState,
ErrorCode
DuplicateKey,
ErrorCode
JsonTypeMismatch,
ErrorCode
LossOfPrecision,
ErrorCode
InvalidMagic,
ErrorCode
InvalidChecksum,
ErrorCode
InvalidBlake2bHashSize,
ErrorCode
InvalidEd25519SignatureSize,
ErrorCode
InvalidEd25519PublicKeySize,
ErrorCode
InvalidEd25519PrivateKeySize,
ErrorCode
InvalidBip32PublicKeySize,
ErrorCode
InvalidBip32PrivateKeySize,
ErrorCode
InvalidBip32DerivationIndex,
ErrorCode
UnexpectedCborType,
ErrorCode
InvalidCborValue,
ErrorCode
InvalidCborArraySize,
ErrorCode
InvalidCborMapSize,
ErrorCode
DuplicateCborMapKey,
ErrorCode
InvalidCborMapKey,
ErrorCode
InvalidAddressType,
ErrorCode
InvalidAddressFormat,
ErrorCode
InvalidCredentialType,
ErrorCode
InvalidPlutusDataConversion,
ErrorCode
InvalidDatumType,
ErrorCode
InvalidScriptLanguage,
ErrorCode
InvalidNativeScriptType,
ErrorCode
InvalidPlutusCostModel,
ErrorCode
InvalidProposalProcedureType,
ErrorCode
InvalidMetadatumConversion,
ErrorCode
InvalidMetadatumTextStringSize,
ErrorCode
InvalidMetadatumBoundedBytesSize,
ErrorCode
InvalidHttpRequest,
ErrorCode
InsufficientBalance,
ErrorCode
UtxoNotFragmentedEnough,
ErrorCode
UtxoFullyDepleted,
ErrorCode
MaximumInputCountExceeded,
ErrorCode
UnbalancedSubTransactions,
ErrorCode
DisallowedSupplementalDatums,
ErrorCode
MissingRedeemer,
ErrorCode
ScriptEvaluationFailure
]