Skip to content

Commit

Permalink
1994 michel codec error improvement (#2536)
Browse files Browse the repository at this point in the history
* refactor: improve @taquito/michel-codec error.ts file

BREAKING CHANGE: In @taquito/michel-codec error class InvalidContractError rename to
invalidMichelsonError

* refactor: imporved error classes in @taquito/michel-codec

* refactor: addressed review comments

* docs: addressed pr comment
  • Loading branch information
hui-an-yang authored Jul 27, 2023
1 parent a8892bc commit a1d95fa
Show file tree
Hide file tree
Showing 31 changed files with 238 additions and 217 deletions.
4 changes: 2 additions & 2 deletions packages/taquito-beacon-wallet/src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { PermissionDeniedError } from '@taquito/core';

/**
* @category Error
* @description Error indicates the Beacon wallet not being initialized
* @description Error that indicates the Beacon wallet not being initialized
*/
export class BeaconWalletNotInitialized extends PermissionDeniedError {
constructor() {
Expand All @@ -16,7 +16,7 @@ export class BeaconWalletNotInitialized extends PermissionDeniedError {

/**
* @category Error
* @description Error indicates missing required persmission scopes
* @description Error that indicates missing required persmission scopes
*/
export class MissingRequiredScopes extends PermissionDeniedError {
constructor(public readonly requiredScopes: PermissionScope[]) {
Expand Down
2 changes: 1 addition & 1 deletion packages/taquito-contracts-library/src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ParameterValidationError } from '@taquito/core';
import { ScriptedContracts } from '@taquito/rpc';
/**
* @category Error
* @description Error indicates invalid script format being useed or passed
* @description Error that indicates invalid script format being useed or passed
*/
export class InvalidScriptFormatError extends ParameterValidationError {
constructor(
Expand Down
38 changes: 19 additions & 19 deletions packages/taquito-core/src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export class TaquitoError extends Error {}

/**
* @category Error
* @description Error indicates invalid user inputs
* @description Error that indicates invalid user inputs
*/
export class ParameterValidationError extends TaquitoError {}

Expand All @@ -21,13 +21,13 @@ export class RpcError extends TaquitoError {}

/**
* @category Error
* @description Error indicates TezosToolKit has not been configured appropriately
* @description Error that indicates TezosToolKit has not been configured appropriately
*/
export class TezosToolkitConfigError extends TaquitoError {}

/**
* @category Error
* @description Error indicates a requested action is not supported by Taquito
* @description Error that indicates a requested action is not supported by Taquito
*/
export class UnsupportedActionError extends TaquitoError {}

Expand All @@ -39,7 +39,7 @@ export class NetworkError extends TaquitoError {}

/**
* @category Error
* @description Error indicates user attempts an action without necessary permissions
* @description Error that indicates user attempts an action without necessary permissions
*/
export class PermissionDeniedError extends TaquitoError {}

Expand All @@ -48,7 +48,7 @@ export class PermissionDeniedError extends TaquitoError {}
// ==========================================================================================
/**
* @category Error
* @description Error indicates an invalid originated or implicit address being passed or used
* @description Error that indicates an invalid originated or implicit address being passed or used
*/
export class InvalidAddressError extends ParameterValidationError {
constructor(public readonly address: string, public readonly errorDetail?: string) {
Expand All @@ -61,7 +61,7 @@ export class InvalidAddressError extends ParameterValidationError {

/**
* @category Error
* @description Error indicates an invalid block hash being passed or used
* @description Error that indicates an invalid block hash being passed or used
*/
export class InvalidBlockHashError extends ParameterValidationError {
constructor(public readonly blockHash: string, public readonly errorDetail?: string) {
Expand All @@ -74,7 +74,7 @@ export class InvalidBlockHashError extends ParameterValidationError {

/**
* @category Error
* @description Error indicates an invalid amount of tez being passed as a parameter
* @description Error that indicates an invalid amount of tez being passed as a parameter
*/
export class InvalidAmountError extends ParameterValidationError {
constructor(public readonly amount: string) {
Expand All @@ -86,7 +86,7 @@ export class InvalidAmountError extends ParameterValidationError {

/**
* @category Error
* @description Error indicates an invalid derivation path being passed or used
* @description Error that indicates an invalid derivation path being passed or used
*/
export class InvalidDerivationPathError extends ParameterValidationError {
constructor(public readonly derivationPath: string, public readonly errorDetail?: string) {
Expand All @@ -99,7 +99,7 @@ export class InvalidDerivationPathError extends ParameterValidationError {

/**
* @category Error
* @description Error indicates an invalid hex string have been passed or used
* @description Error that indicates an invalid hex string have been passed or used
*/
export class InvalidHexStringError extends ParameterValidationError {
constructor(public readonly hexString: string, public readonly errorDetail?: string) {
Expand All @@ -125,7 +125,7 @@ export class InvalidMessageError extends ParameterValidationError {

/**
* @category Error
* @description Error indicates invalid view parameter of a smart contract
* @description Error that indicates invalid view parameter of a smart contract
*/
export class InvalidViewParameterError extends ParameterValidationError {
constructor(
Expand All @@ -146,7 +146,7 @@ export class InvalidViewParameterError extends ParameterValidationError {

/**
* @category Error
* @description Error indicates an invalid private key being passed or used
* @description Error that indicates an invalid private key being passed or used
*/
export class InvalidKeyError extends ParameterValidationError {
constructor(public readonly errorDetail?: string) {
Expand All @@ -159,7 +159,7 @@ export class InvalidKeyError extends ParameterValidationError {

/**
* @category Error
* @description Error indicates an Invalid Public Key being passed or used
* @description Error that indicates an Invalid Public Key being passed or used
*/
export class InvalidPublicKeyError extends ParameterValidationError {
constructor(public readonly publicKey: string, readonly errorDetail?: string) {
Expand All @@ -172,7 +172,7 @@ export class InvalidPublicKeyError extends ParameterValidationError {

/**
* @category Error
* @description Error indicates an invalid signature being passed or used
* @description Error that indicates an invalid signature being passed or used
*/
export class InvalidSignatureError extends ParameterValidationError {
constructor(public readonly signature: string, public readonly errorDetail?: string) {
Expand All @@ -185,7 +185,7 @@ export class InvalidSignatureError extends ParameterValidationError {

/**
* @category Error
* @description Error indicates an invalid contract address being passed or used
* @description Error that indicates an invalid contract address being passed or used
*/
export class InvalidContractAddressError extends ParameterValidationError {
constructor(public readonly contractAddress: string, public readonly errorDetail?: string) {
Expand All @@ -198,7 +198,7 @@ export class InvalidContractAddressError extends ParameterValidationError {

/**
* @category Error
* @description Error indicates an invalid chain id being passed or used
* @description Error that indicates an invalid chain id being passed or used
*/
export class InvalidChainIdError extends ParameterValidationError {
constructor(public readonly chainId: string, public readonly errorDetail?: string) {
Expand All @@ -211,7 +211,7 @@ export class InvalidChainIdError extends ParameterValidationError {

/**
* @category Error
* @description Error indicates an invalid public key hash being passed or used
* @description Error that indicates an invalid public key hash being passed or used
*/
export class InvalidKeyHashError extends ParameterValidationError {
constructor(public readonly keyHash: string, public readonly errorDetail?: string) {
Expand All @@ -224,7 +224,7 @@ export class InvalidKeyHashError extends ParameterValidationError {

/**
* @category Error
* @description Error indicates an invalid operation hash being passed or used
* @description Error that indicates an invalid operation hash being passed or used
*/
export class InvalidOperationHashError extends ParameterValidationError {
constructor(public readonly operationHash: string, public readonly errorDetail?: string) {
Expand All @@ -237,7 +237,7 @@ export class InvalidOperationHashError extends ParameterValidationError {

/**
* @category Error
* @description Error indicates an invalid operation kind being passed or used
* @description Error that indicates an invalid operation kind being passed or used
*/
export class InvalidOperationKindError extends ParameterValidationError {
constructor(public readonly operationKind: string, public readonly errorDetail?: string) {
Expand Down Expand Up @@ -272,7 +272,7 @@ export class ProhibitedActionError extends UnsupportedActionError {

/**
* @category Error
* @description Error indicates a failure in grabbing the public key
* @description Error that indicates a failure in grabbing the public key
*/
export class PublicKeyNotFoundError extends TaquitoError {
constructor(public readonly pkh: string, public readonly cause?: any) {
Expand Down
2 changes: 1 addition & 1 deletion packages/taquito-http-utils/src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { STATUS_CODE } from './status_code';

/**
* @category Error
* @description Error indicates a general failure in making the HTTP request
* @description Error that indicates a general failure in making the HTTP request
*/
export class HttpRequestFailed extends NetworkError {
constructor(
Expand Down
8 changes: 4 additions & 4 deletions packages/taquito-ledger-signer/src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ParameterValidationError, TaquitoError } from '@taquito/core';

/**
* @category Error
* @description Error indicates an invalid or unparseable ledger response
* @description Error that indicates an invalid or unparseable ledger response
*/
export class InvalidLedgerResponseError extends TaquitoError {
constructor(public readonly message: string) {
Expand All @@ -13,7 +13,7 @@ export class InvalidLedgerResponseError extends TaquitoError {

/**
* @category Error
* @description Error indicates a failure when trying to retrieve a Public Key from Ledger signer
* @description Error that indicates a failure when trying to retrieve a Public Key from Ledger signer
*/
export class PublicKeyRetrievalError extends TaquitoError {
constructor(public readonly cause: any) {
Expand All @@ -25,7 +25,7 @@ export class PublicKeyRetrievalError extends TaquitoError {

/**
* @category Error
* @description Error indicates a failure when trying to retrieve a Public Key Hash from Ledger signer
* @description Error that indicates a failure when trying to retrieve a Public Key Hash from Ledger signer
*/
export class PublicKeyHashRetrievalError extends TaquitoError {
constructor() {
Expand All @@ -37,7 +37,7 @@ export class PublicKeyHashRetrievalError extends TaquitoError {

/**
* @category Error
* @description Error indicates an invalid derivation type being passed or used
* @description Error that indicates an invalid derivation type being passed or used
*/
export class InvalidDerivationTypeError extends ParameterValidationError {
constructor(public readonly derivationType: string) {
Expand Down
24 changes: 12 additions & 12 deletions packages/taquito-local-forging/src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ENTRYPOINT_MAX_LENGTH } from './constants';

/**
* @category Error
* @description Error indicates an invalid operation content being passed or used
* @description Error that indicates an invalid operation content being passed or used
*/ export class InvalidOperationSchemaError extends ParameterValidationError {
constructor(public readonly operation: OperationContents, public readonly errorDetail?: string) {
super();
Expand All @@ -16,7 +16,7 @@ import { ENTRYPOINT_MAX_LENGTH } from './constants';

/**
* @category Error
* @description Error indicates an entrypoint name exceeding maximum length
* @description Error that indicates an entrypoint name exceeding maximum length
*/
export class OversizedEntryPointError extends ParameterValidationError {
constructor(public readonly entrypoint: string) {
Expand All @@ -28,7 +28,7 @@ export class OversizedEntryPointError extends ParameterValidationError {

/**
* @category Error
* @description Error indicates an invalid ballot value being used
* @description Error that indicates an invalid ballot value being used
*/
export class InvalidBallotValueError extends ParameterValidationError {
constructor(public readonly ballotValue: string) {
Expand All @@ -40,7 +40,7 @@ export class InvalidBallotValueError extends ParameterValidationError {

/**
* @category Error
* @description Error indicates a failure when trying to decode ballot value
* @description Error that indicates a failure when trying to decode ballot value
*/
export class DecodeBallotValueError extends ParameterValidationError {
constructor(public readonly ballotValue: string) {
Expand All @@ -52,7 +52,7 @@ export class DecodeBallotValueError extends ParameterValidationError {

/**
* @category Error
* @description Error indicates unexpected Michelson Value being passed or used
* @description Error that indicates unexpected Michelson Value being passed or used
*/
export class UnexpectedMichelsonValueError extends ParameterValidationError {
constructor(public readonly value: string) {
Expand All @@ -64,7 +64,7 @@ export class UnexpectedMichelsonValueError extends ParameterValidationError {

/**
* @category Error
* @description Error indicates a failure when trying to decode an operation
* @description Error that indicates a failure when trying to decode an operation
*/
export class OperationDecodingError extends ParameterValidationError {
constructor(public readonly message: string) {
Expand All @@ -75,7 +75,7 @@ export class OperationDecodingError extends ParameterValidationError {

/**
* @category Error
* @description Error indicates a failure when trying to encode an operation
* @description Error that indicates a failure when trying to encode an operation
*/
export class OperationEncodingError extends ParameterValidationError {
constructor(public readonly message: string) {
Expand All @@ -86,7 +86,7 @@ export class OperationEncodingError extends ParameterValidationError {

/**
* @category Error
* @description Error indicates an unsupported operation being passed or used
* @description Error that indicates an unsupported operation being passed or used
*/
export class UnsupportedOperationError extends ParameterValidationError {
constructor(public readonly op: string) {
Expand All @@ -98,7 +98,7 @@ export class UnsupportedOperationError extends ParameterValidationError {

/**
* @cateogry Error
* @description Error indicates an unsupported pvm being passed or used
* @description Error that indicates an unsupported pvm being passed or used
*/
export class UnsupportedPvmKindError extends ParameterValidationError {
constructor(public readonly pvm: string) {
Expand All @@ -110,7 +110,7 @@ export class UnsupportedPvmKindError extends ParameterValidationError {

/**
* @category Error
* @description Error indicates an unsupported pvm to decode
* @description Error that indicates an unsupported pvm to decode
*/
export class DecodePvmKindError extends ParameterValidationError {
constructor(public readonly pvm: string) {
Expand All @@ -122,7 +122,7 @@ export class DecodePvmKindError extends ParameterValidationError {

/**
* @category Error
* @description Error indicates an invalid Smart Rollup Address (sr1)
* @description Error that indicates an invalid Smart Rollup Address (sr1)
*/
export class InvalidSmartRollupAddressError extends ParameterValidationError {
constructor(public readonly address: string, public readonly errorDetail?: string) {
Expand All @@ -135,7 +135,7 @@ export class InvalidSmartRollupAddressError extends ParameterValidationError {

/**
* @category Error
* @description Error indicates an invalid Smart Rollup commitment hash (src1)
* @description Error that indicates an invalid Smart Rollup commitment hash (src1)
*/
export class InvalidSmartRollupCommitmentHashError extends ParameterValidationError {
constructor(public readonly hash: string, public readonly errorDetail?: string) {
Expand Down
10 changes: 5 additions & 5 deletions packages/taquito-michel-codec/src/base58.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { InvalidMessageError } from '@taquito/core';
import { InvalidMessageError, TaquitoError } from '@taquito/core';

const H = [
0x6a09e667 | 0,
Expand Down Expand Up @@ -82,10 +82,10 @@ const K = [
* @category Error
* @description Error that indicates a failure when decoding a base58 encoding
*/
export class Base58DecodingError extends Error {
public name = 'Base58DecodingError';
constructor(public message: string) {
super(message);
export class Base58DecodingError extends TaquitoError {
constructor(public readonly message: string) {
super();
this.name = 'Base58DecodingError';
}
}

Expand Down
Loading

0 comments on commit a1d95fa

Please sign in to comment.