@vechain/sdk-errors
Advanced tools
Comparing version 1.0.0-beta.21 to 1.0.0-beta.22
@@ -568,2 +568,121 @@ /** | ||
/** | ||
* Function to build the error message. | ||
* Here, we can customize the error message format. | ||
* | ||
* @param methodName The name of the method that failed. | ||
* @param errorMessage The error message. | ||
* @param inputData The input data that caused the error. | ||
* @param innerError The inner error that caused the error. | ||
* @returns The error message as a string. | ||
*/ | ||
declare function createErrorMessage<TErrorDataType>(methodName: string, errorMessage: string, inputData: TErrorDataType, innerError?: Error): string; | ||
/** | ||
* Generic error class for SDK errors. | ||
* | ||
* Each error of SDK should extend this class. | ||
* And, then, error must redefine properly the TErrorDataType generic type. | ||
* In this way, the error will have a specific data type. | ||
*/ | ||
declare class VechainSDKError<TErrorDataType> extends Error { | ||
readonly methodName: string; | ||
readonly errorMessage: string; | ||
readonly data: TErrorDataType; | ||
readonly innerError?: unknown | undefined; | ||
constructor(methodName: string, errorMessage: string, data: TErrorDataType, innerError?: unknown | undefined); | ||
} | ||
/** | ||
* Default Object error data type. it accepts any object. | ||
*/ | ||
type ObjectErrorData = Record<string, unknown>; | ||
/** | ||
* Invalid data to encode/decode abi. | ||
* | ||
* This error is thrown when the data to encode or decode into abi is invalid. | ||
*/ | ||
declare class InvalidAbiDataToEncodeOrDecode extends VechainSDKError<ObjectErrorData> { | ||
} | ||
/** | ||
* Invalid fragment type. | ||
* | ||
* This error is thrown when the fragment type is invalid. | ||
*/ | ||
declare class InvalidAbiFragment extends VechainSDKError<{ | ||
type: 'function' | 'event'; | ||
fragment: unknown; | ||
}> { | ||
} | ||
/** | ||
* Invalid abi signature format. | ||
* | ||
* This error is thrown when the abi signature format is invalid. | ||
*/ | ||
declare class InvalidAbiSignatureFormat extends VechainSDKError<{ | ||
signatureFormat: string; | ||
}> { | ||
} | ||
/** | ||
* Invalid address error to be thrown when an invalid address is detected. | ||
* | ||
* This error is thrown when an invalid address is detected. | ||
*/ | ||
declare class InvalidAddress extends VechainSDKError<{ | ||
address: string; | ||
}> { | ||
} | ||
/** | ||
* Invalid data error to be thrown when invalid data is detected. | ||
* | ||
* This error is thrown when invalid data is detected. | ||
*/ | ||
declare class InvalidDataType extends VechainSDKError<ObjectErrorData> { | ||
} | ||
/** | ||
* Invalid RLP error is thrown. | ||
* | ||
* This error is thrown when an invalid RLP is detected. | ||
*/ | ||
declare class InvalidRLP extends VechainSDKError<{ | ||
context: string; | ||
data: ObjectErrorData; | ||
}> { | ||
} | ||
/** | ||
* Invalid private error to be thrown when an invalid private key is detected. | ||
* | ||
* This error is thrown when an invalid private key is detected. | ||
* | ||
* @note Data is null because for security reasons, the private key should not be logged! | ||
*/ | ||
declare class InvalidSecp256k1PrivateKey extends VechainSDKError<undefined> { | ||
} | ||
/** | ||
* Invalid message hash error to be thrown when an invalid message hash is detected. | ||
* | ||
* This error is thrown when an invalid message hash is detected. | ||
*/ | ||
declare class InvalidSecp256k1MessageHash extends VechainSDKError<{ | ||
messageHash: Uint8Array; | ||
}> { | ||
} | ||
/** | ||
* Unavailable transaction field name. | ||
* | ||
* This error is thrown a field name in a transaction is unavailable. | ||
* | ||
* e.g. we want to get the value of 'delegator' or 'id' or 'origin' from a not signed transaction | ||
*/ | ||
declare class UnavailableTransactionField extends VechainSDKError<{ | ||
fieldName: string; | ||
}> { | ||
} | ||
/** | ||
* Builds an error object with the error code provided and specified parameters. | ||
@@ -711,2 +830,4 @@ * | ||
declare const errors_InvalidAbiDataToEncodeError: typeof InvalidAbiDataToEncodeError; | ||
type errors_InvalidAbiDataToEncodeOrDecode = InvalidAbiDataToEncodeOrDecode; | ||
declare const errors_InvalidAbiDataToEncodeOrDecode: typeof InvalidAbiDataToEncodeOrDecode; | ||
type errors_InvalidAbiEventError = InvalidAbiEventError; | ||
@@ -716,4 +837,10 @@ declare const errors_InvalidAbiEventError: typeof InvalidAbiEventError; | ||
declare const errors_InvalidAbiFormatTypeError: typeof InvalidAbiFormatTypeError; | ||
type errors_InvalidAbiFragment = InvalidAbiFragment; | ||
declare const errors_InvalidAbiFragment: typeof InvalidAbiFragment; | ||
type errors_InvalidAbiFunctionError = InvalidAbiFunctionError; | ||
declare const errors_InvalidAbiFunctionError: typeof InvalidAbiFunctionError; | ||
type errors_InvalidAbiSignatureFormat = InvalidAbiSignatureFormat; | ||
declare const errors_InvalidAbiSignatureFormat: typeof InvalidAbiSignatureFormat; | ||
type errors_InvalidAddress = InvalidAddress; | ||
declare const errors_InvalidAddress: typeof InvalidAddress; | ||
type errors_InvalidAddressError = InvalidAddressError; | ||
@@ -725,2 +852,4 @@ declare const errors_InvalidAddressError: typeof InvalidAddressError; | ||
declare const errors_InvalidDataReturnTypeError: typeof InvalidDataReturnTypeError; | ||
type errors_InvalidDataType = InvalidDataType; | ||
declare const errors_InvalidDataType: typeof InvalidDataType; | ||
type errors_InvalidDataTypeError = InvalidDataTypeError; | ||
@@ -744,7 +873,13 @@ declare const errors_InvalidDataTypeError: typeof InvalidDataTypeError; | ||
declare const errors_InvalidKeystorePasswordError: typeof InvalidKeystorePasswordError; | ||
type errors_InvalidRLP = InvalidRLP; | ||
declare const errors_InvalidRLP: typeof InvalidRLP; | ||
type errors_InvalidRLPError = InvalidRLPError; | ||
declare const errors_InvalidRLPError: typeof InvalidRLPError; | ||
type errors_InvalidRLPErrorData = InvalidRLPErrorData; | ||
type errors_InvalidSecp256k1MessageHash = InvalidSecp256k1MessageHash; | ||
declare const errors_InvalidSecp256k1MessageHash: typeof InvalidSecp256k1MessageHash; | ||
type errors_InvalidSecp256k1MessageHashError = InvalidSecp256k1MessageHashError; | ||
declare const errors_InvalidSecp256k1MessageHashError: typeof InvalidSecp256k1MessageHashError; | ||
type errors_InvalidSecp256k1PrivateKey = InvalidSecp256k1PrivateKey; | ||
declare const errors_InvalidSecp256k1PrivateKey: typeof InvalidSecp256k1PrivateKey; | ||
type errors_InvalidSecp256k1PrivateKeyError = InvalidSecp256k1PrivateKeyError; | ||
@@ -771,2 +906,3 @@ declare const errors_InvalidSecp256k1PrivateKeyError: typeof InvalidSecp256k1PrivateKeyError; | ||
declare const errors_NotImplementedError: typeof NotImplementedError; | ||
type errors_ObjectErrorData = ObjectErrorData; | ||
type errors_POLL_ERROR = POLL_ERROR; | ||
@@ -795,2 +931,6 @@ declare const errors_POLL_ERROR: typeof POLL_ERROR; | ||
declare const errors_TransactionNotSignedError: typeof TransactionNotSignedError; | ||
type errors_UnavailableTransactionField = UnavailableTransactionField; | ||
declare const errors_UnavailableTransactionField: typeof UnavailableTransactionField; | ||
type errors_VechainSDKError<TErrorDataType> = VechainSDKError<TErrorDataType>; | ||
declare const errors_VechainSDKError: typeof VechainSDKError; | ||
declare const errors_assert: typeof assert; | ||
@@ -801,2 +941,3 @@ declare const errors_assertInnerError: typeof assertInnerError; | ||
declare const errors_buildProviderError: typeof buildProviderError; | ||
declare const errors_createErrorMessage: typeof createErrorMessage; | ||
declare const errors_getEIP1193ErrorCode: typeof getEIP1193ErrorCode; | ||
@@ -806,5 +947,5 @@ declare const errors_getJSONRPCErrorCode: typeof getJSONRPCErrorCode; | ||
declare namespace errors { | ||
export { errors_ABI as ABI, errors_ADDRESS as ADDRESS, errors_BLOOM as BLOOM, errors_CERTIFICATE as CERTIFICATE, errors_CONTRACT as CONTRACT, errors_CertificateInvalidSignatureFormatError as CertificateInvalidSignatureFormatError, errors_CertificateInvalidSignerError as CertificateInvalidSignerError, errors_CertificateNotSignedError as CertificateNotSignedError, errors_ContractDeploymentFailedError as ContractDeploymentFailedError, errors_ContractInterfaceError as ContractInterfaceError, errors_DATA as DATA, type errors_DataType as DataType, type errors_DefaultErrorData as DefaultErrorData, errors_EIP1193 as EIP1193, errors_EIP1193ChainDisconnected as EIP1193ChainDisconnected, errors_EIP1193Disconnected as EIP1193Disconnected, type errors_EIP1193ProviderRpcErrorData as EIP1193ProviderRpcErrorData, errors_EIP1193Unauthorized as EIP1193Unauthorized, errors_EIP1193UnsupportedMethod as EIP1193UnsupportedMethod, errors_EIP1193UserRejectedRequest as EIP1193UserRejectedRequest, errors_ERROR_CODES as ERROR_CODES, errors_ErrorBase as ErrorBase, errors_ErrorClassMap as ErrorClassMap, type errors_ErrorCode as ErrorCode, type errors_ErrorType as ErrorType, errors_FUNCTION as FUNCTION, errors_HDNODE as HDNODE, errors_HTTPClientError as HTTPClientError, type errors_HTTPClientErrorData as HTTPClientErrorData, errors_HTTP_CLIENT as HTTP_CLIENT, errors_InvalidAbiDataToDecodeError as InvalidAbiDataToDecodeError, errors_InvalidAbiDataToEncodeError as InvalidAbiDataToEncodeError, errors_InvalidAbiEventError as InvalidAbiEventError, errors_InvalidAbiFormatTypeError as InvalidAbiFormatTypeError, errors_InvalidAbiFunctionError as InvalidAbiFunctionError, errors_InvalidAddressError as InvalidAddressError, errors_InvalidBloomError as InvalidBloomError, errors_InvalidDataReturnTypeError as InvalidDataReturnTypeError, errors_InvalidDataTypeError as InvalidDataTypeError, errors_InvalidHDNodeChaincodeError as InvalidHDNodeChaincodeError, errors_InvalidHDNodeDerivationPathError as InvalidHDNodeDerivationPathError, errors_InvalidHDNodeMnemonicsError as InvalidHDNodeMnemonicsError, errors_InvalidHDNodePrivateKeyError as InvalidHDNodePrivateKeyError, errors_InvalidHDNodePublicKeyError as InvalidHDNodePublicKeyError, errors_InvalidKError as InvalidKError, errors_InvalidKeystoreError as InvalidKeystoreError, errors_InvalidKeystorePasswordError as InvalidKeystorePasswordError, errors_InvalidRLPError as InvalidRLPError, type errors_InvalidRLPErrorData as InvalidRLPErrorData, errors_InvalidSecp256k1MessageHashError as InvalidSecp256k1MessageHashError, errors_InvalidSecp256k1PrivateKeyError as InvalidSecp256k1PrivateKeyError, errors_InvalidSecp256k1SignatureError as InvalidSecp256k1SignatureError, errors_InvalidSecp256k1SignatureRecoveryError as InvalidSecp256k1SignatureRecoveryError, errors_JSONRPC as JSONRPC, errors_JSONRPCDefaultError as JSONRPCDefaultError, type errors_JSONRPCErrorData as JSONRPCErrorData, errors_JSONRPCInternalError as JSONRPCInternalError, errors_JSONRPCInvalidParams as JSONRPCInvalidParams, errors_JSONRPCInvalidRequest as JSONRPCInvalidRequest, errors_KEYSTORE as KEYSTORE, errors_NotImplementedError as NotImplementedError, errors_POLL_ERROR as POLL_ERROR, type errors_PollErrorData as PollErrorData, errors_PollExecutionError as PollExecutionError, errors_ProviderRpcError as ProviderRpcError, errors_RLP_ERRORS as RLP_ERRORS, errors_SECP256K1 as SECP256K1, errors_TRANSACTION as TRANSACTION, errors_TransactionAlreadySignedError as TransactionAlreadySignedError, errors_TransactionBodyError as TransactionBodyError, errors_TransactionDelegationError as TransactionDelegationError, errors_TransactionMissingPrivateKeyError as TransactionMissingPrivateKeyError, errors_TransactionNotSignedError as TransactionNotSignedError, errors_assert as assert, errors_assertInnerError as assertInnerError, errors_buildError as buildError, errors_buildErrorMessage as buildErrorMessage, errors_buildProviderError as buildProviderError, errors_getEIP1193ErrorCode as getEIP1193ErrorCode, errors_getJSONRPCErrorCode as getJSONRPCErrorCode, errors_stringifyData as stringifyData }; | ||
export { errors_ABI as ABI, errors_ADDRESS as ADDRESS, errors_BLOOM as BLOOM, errors_CERTIFICATE as CERTIFICATE, errors_CONTRACT as CONTRACT, errors_CertificateInvalidSignatureFormatError as CertificateInvalidSignatureFormatError, errors_CertificateInvalidSignerError as CertificateInvalidSignerError, errors_CertificateNotSignedError as CertificateNotSignedError, errors_ContractDeploymentFailedError as ContractDeploymentFailedError, errors_ContractInterfaceError as ContractInterfaceError, errors_DATA as DATA, type errors_DataType as DataType, type errors_DefaultErrorData as DefaultErrorData, errors_EIP1193 as EIP1193, errors_EIP1193ChainDisconnected as EIP1193ChainDisconnected, errors_EIP1193Disconnected as EIP1193Disconnected, type errors_EIP1193ProviderRpcErrorData as EIP1193ProviderRpcErrorData, errors_EIP1193Unauthorized as EIP1193Unauthorized, errors_EIP1193UnsupportedMethod as EIP1193UnsupportedMethod, errors_EIP1193UserRejectedRequest as EIP1193UserRejectedRequest, errors_ERROR_CODES as ERROR_CODES, errors_ErrorBase as ErrorBase, errors_ErrorClassMap as ErrorClassMap, type errors_ErrorCode as ErrorCode, type errors_ErrorType as ErrorType, errors_FUNCTION as FUNCTION, errors_HDNODE as HDNODE, errors_HTTPClientError as HTTPClientError, type errors_HTTPClientErrorData as HTTPClientErrorData, errors_HTTP_CLIENT as HTTP_CLIENT, errors_InvalidAbiDataToDecodeError as InvalidAbiDataToDecodeError, errors_InvalidAbiDataToEncodeError as InvalidAbiDataToEncodeError, errors_InvalidAbiDataToEncodeOrDecode as InvalidAbiDataToEncodeOrDecode, errors_InvalidAbiEventError as InvalidAbiEventError, errors_InvalidAbiFormatTypeError as InvalidAbiFormatTypeError, errors_InvalidAbiFragment as InvalidAbiFragment, errors_InvalidAbiFunctionError as InvalidAbiFunctionError, errors_InvalidAbiSignatureFormat as InvalidAbiSignatureFormat, errors_InvalidAddress as InvalidAddress, errors_InvalidAddressError as InvalidAddressError, errors_InvalidBloomError as InvalidBloomError, errors_InvalidDataReturnTypeError as InvalidDataReturnTypeError, errors_InvalidDataType as InvalidDataType, errors_InvalidDataTypeError as InvalidDataTypeError, errors_InvalidHDNodeChaincodeError as InvalidHDNodeChaincodeError, errors_InvalidHDNodeDerivationPathError as InvalidHDNodeDerivationPathError, errors_InvalidHDNodeMnemonicsError as InvalidHDNodeMnemonicsError, errors_InvalidHDNodePrivateKeyError as InvalidHDNodePrivateKeyError, errors_InvalidHDNodePublicKeyError as InvalidHDNodePublicKeyError, errors_InvalidKError as InvalidKError, errors_InvalidKeystoreError as InvalidKeystoreError, errors_InvalidKeystorePasswordError as InvalidKeystorePasswordError, errors_InvalidRLP as InvalidRLP, errors_InvalidRLPError as InvalidRLPError, type errors_InvalidRLPErrorData as InvalidRLPErrorData, errors_InvalidSecp256k1MessageHash as InvalidSecp256k1MessageHash, errors_InvalidSecp256k1MessageHashError as InvalidSecp256k1MessageHashError, errors_InvalidSecp256k1PrivateKey as InvalidSecp256k1PrivateKey, errors_InvalidSecp256k1PrivateKeyError as InvalidSecp256k1PrivateKeyError, errors_InvalidSecp256k1SignatureError as InvalidSecp256k1SignatureError, errors_InvalidSecp256k1SignatureRecoveryError as InvalidSecp256k1SignatureRecoveryError, errors_JSONRPC as JSONRPC, errors_JSONRPCDefaultError as JSONRPCDefaultError, type errors_JSONRPCErrorData as JSONRPCErrorData, errors_JSONRPCInternalError as JSONRPCInternalError, errors_JSONRPCInvalidParams as JSONRPCInvalidParams, errors_JSONRPCInvalidRequest as JSONRPCInvalidRequest, errors_KEYSTORE as KEYSTORE, errors_NotImplementedError as NotImplementedError, type errors_ObjectErrorData as ObjectErrorData, errors_POLL_ERROR as POLL_ERROR, type errors_PollErrorData as PollErrorData, errors_PollExecutionError as PollExecutionError, errors_ProviderRpcError as ProviderRpcError, errors_RLP_ERRORS as RLP_ERRORS, errors_SECP256K1 as SECP256K1, errors_TRANSACTION as TRANSACTION, errors_TransactionAlreadySignedError as TransactionAlreadySignedError, errors_TransactionBodyError as TransactionBodyError, errors_TransactionDelegationError as TransactionDelegationError, errors_TransactionMissingPrivateKeyError as TransactionMissingPrivateKeyError, errors_TransactionNotSignedError as TransactionNotSignedError, errors_UnavailableTransactionField as UnavailableTransactionField, errors_VechainSDKError as VechainSDKError, errors_assert as assert, errors_assertInnerError as assertInnerError, errors_buildError as buildError, errors_buildErrorMessage as buildErrorMessage, errors_buildProviderError as buildProviderError, errors_createErrorMessage as createErrorMessage, errors_getEIP1193ErrorCode as getEIP1193ErrorCode, errors_getJSONRPCErrorCode as getJSONRPCErrorCode, errors_stringifyData as stringifyData }; | ||
} | ||
export { ABI, ADDRESS, BLOOM, CERTIFICATE, CONTRACT, CertificateInvalidSignatureFormatError, CertificateInvalidSignerError, CertificateNotSignedError, ContractDeploymentFailedError, ContractInterfaceError, DATA, type DataType, type DefaultErrorData, EIP1193, EIP1193ChainDisconnected, EIP1193Disconnected, type EIP1193ProviderRpcErrorData, EIP1193Unauthorized, EIP1193UnsupportedMethod, EIP1193UserRejectedRequest, ERROR_CODES, ErrorBase, ErrorClassMap, type ErrorCode, type ErrorType, FUNCTION, HDNODE, HTTPClientError, type HTTPClientErrorData, HTTP_CLIENT, InvalidAbiDataToDecodeError, InvalidAbiDataToEncodeError, InvalidAbiEventError, InvalidAbiFormatTypeError, InvalidAbiFunctionError, InvalidAddressError, InvalidBloomError, InvalidDataReturnTypeError, InvalidDataTypeError, InvalidHDNodeChaincodeError, InvalidHDNodeDerivationPathError, InvalidHDNodeMnemonicsError, InvalidHDNodePrivateKeyError, InvalidHDNodePublicKeyError, InvalidKError, InvalidKeystoreError, InvalidKeystorePasswordError, InvalidRLPError, type InvalidRLPErrorData, InvalidSecp256k1MessageHashError, InvalidSecp256k1PrivateKeyError, InvalidSecp256k1SignatureError, InvalidSecp256k1SignatureRecoveryError, JSONRPC, JSONRPCDefaultError, type JSONRPCErrorData, JSONRPCInternalError, JSONRPCInvalidParams, JSONRPCInvalidRequest, KEYSTORE, NotImplementedError, POLL_ERROR, type PollErrorData, PollExecutionError, ProviderRpcError, RLP_ERRORS, SECP256K1, TRANSACTION, TransactionAlreadySignedError, TransactionBodyError, TransactionDelegationError, TransactionMissingPrivateKeyError, TransactionNotSignedError, assert, assertInnerError, buildError, buildErrorMessage, buildProviderError, errors, getEIP1193ErrorCode, getJSONRPCErrorCode, stringifyData }; | ||
export { ABI, ADDRESS, BLOOM, CERTIFICATE, CONTRACT, CertificateInvalidSignatureFormatError, CertificateInvalidSignerError, CertificateNotSignedError, ContractDeploymentFailedError, ContractInterfaceError, DATA, type DataType, type DefaultErrorData, EIP1193, EIP1193ChainDisconnected, EIP1193Disconnected, type EIP1193ProviderRpcErrorData, EIP1193Unauthorized, EIP1193UnsupportedMethod, EIP1193UserRejectedRequest, ERROR_CODES, ErrorBase, ErrorClassMap, type ErrorCode, type ErrorType, FUNCTION, HDNODE, HTTPClientError, type HTTPClientErrorData, HTTP_CLIENT, InvalidAbiDataToDecodeError, InvalidAbiDataToEncodeError, InvalidAbiDataToEncodeOrDecode, InvalidAbiEventError, InvalidAbiFormatTypeError, InvalidAbiFragment, InvalidAbiFunctionError, InvalidAbiSignatureFormat, InvalidAddress, InvalidAddressError, InvalidBloomError, InvalidDataReturnTypeError, InvalidDataType, InvalidDataTypeError, InvalidHDNodeChaincodeError, InvalidHDNodeDerivationPathError, InvalidHDNodeMnemonicsError, InvalidHDNodePrivateKeyError, InvalidHDNodePublicKeyError, InvalidKError, InvalidKeystoreError, InvalidKeystorePasswordError, InvalidRLP, InvalidRLPError, type InvalidRLPErrorData, InvalidSecp256k1MessageHash, InvalidSecp256k1MessageHashError, InvalidSecp256k1PrivateKey, InvalidSecp256k1PrivateKeyError, InvalidSecp256k1SignatureError, InvalidSecp256k1SignatureRecoveryError, JSONRPC, JSONRPCDefaultError, type JSONRPCErrorData, JSONRPCInternalError, JSONRPCInvalidParams, JSONRPCInvalidRequest, KEYSTORE, NotImplementedError, type ObjectErrorData, POLL_ERROR, type PollErrorData, PollExecutionError, ProviderRpcError, RLP_ERRORS, SECP256K1, TRANSACTION, TransactionAlreadySignedError, TransactionBodyError, TransactionDelegationError, TransactionMissingPrivateKeyError, TransactionNotSignedError, UnavailableTransactionField, VechainSDKError, assert, assertInnerError, buildError, buildErrorMessage, buildProviderError, createErrorMessage, errors, getEIP1193ErrorCode, getJSONRPCErrorCode, stringifyData }; |
@@ -49,8 +49,13 @@ "use strict"; | ||
InvalidAbiDataToEncodeError: () => InvalidAbiDataToEncodeError, | ||
InvalidAbiDataToEncodeOrDecode: () => InvalidAbiDataToEncodeOrDecode, | ||
InvalidAbiEventError: () => InvalidAbiEventError, | ||
InvalidAbiFormatTypeError: () => InvalidAbiFormatTypeError, | ||
InvalidAbiFragment: () => InvalidAbiFragment, | ||
InvalidAbiFunctionError: () => InvalidAbiFunctionError, | ||
InvalidAbiSignatureFormat: () => InvalidAbiSignatureFormat, | ||
InvalidAddress: () => InvalidAddress, | ||
InvalidAddressError: () => InvalidAddressError, | ||
InvalidBloomError: () => InvalidBloomError, | ||
InvalidDataReturnTypeError: () => InvalidDataReturnTypeError, | ||
InvalidDataType: () => InvalidDataType, | ||
InvalidDataTypeError: () => InvalidDataTypeError, | ||
@@ -65,4 +70,7 @@ InvalidHDNodeChaincodeError: () => InvalidHDNodeChaincodeError, | ||
InvalidKeystorePasswordError: () => InvalidKeystorePasswordError, | ||
InvalidRLP: () => InvalidRLP, | ||
InvalidRLPError: () => InvalidRLPError, | ||
InvalidSecp256k1MessageHash: () => InvalidSecp256k1MessageHash, | ||
InvalidSecp256k1MessageHashError: () => InvalidSecp256k1MessageHashError, | ||
InvalidSecp256k1PrivateKey: () => InvalidSecp256k1PrivateKey, | ||
InvalidSecp256k1PrivateKeyError: () => InvalidSecp256k1PrivateKeyError, | ||
@@ -89,2 +97,4 @@ InvalidSecp256k1SignatureError: () => InvalidSecp256k1SignatureError, | ||
TransactionNotSignedError: () => TransactionNotSignedError, | ||
UnavailableTransactionField: () => UnavailableTransactionField, | ||
VechainSDKError: () => VechainSDKError, | ||
assert: () => assert, | ||
@@ -95,6 +105,7 @@ assertInnerError: () => assertInnerError, | ||
buildProviderError: () => buildProviderError, | ||
createErrorMessage: () => createErrorMessage, | ||
errors: () => errors_exports, | ||
getEIP1193ErrorCode: () => getEIP1193ErrorCode, | ||
getJSONRPCErrorCode: () => getJSONRPCErrorCode, | ||
stringifyData: () => stringifyData | ||
stringifyData: () => stringifyData2 | ||
}); | ||
@@ -132,8 +143,13 @@ module.exports = __toCommonJS(src_exports); | ||
InvalidAbiDataToEncodeError: () => InvalidAbiDataToEncodeError, | ||
InvalidAbiDataToEncodeOrDecode: () => InvalidAbiDataToEncodeOrDecode, | ||
InvalidAbiEventError: () => InvalidAbiEventError, | ||
InvalidAbiFormatTypeError: () => InvalidAbiFormatTypeError, | ||
InvalidAbiFragment: () => InvalidAbiFragment, | ||
InvalidAbiFunctionError: () => InvalidAbiFunctionError, | ||
InvalidAbiSignatureFormat: () => InvalidAbiSignatureFormat, | ||
InvalidAddress: () => InvalidAddress, | ||
InvalidAddressError: () => InvalidAddressError, | ||
InvalidBloomError: () => InvalidBloomError, | ||
InvalidDataReturnTypeError: () => InvalidDataReturnTypeError, | ||
InvalidDataType: () => InvalidDataType, | ||
InvalidDataTypeError: () => InvalidDataTypeError, | ||
@@ -148,4 +164,7 @@ InvalidHDNodeChaincodeError: () => InvalidHDNodeChaincodeError, | ||
InvalidKeystorePasswordError: () => InvalidKeystorePasswordError, | ||
InvalidRLP: () => InvalidRLP, | ||
InvalidRLPError: () => InvalidRLPError, | ||
InvalidSecp256k1MessageHash: () => InvalidSecp256k1MessageHash, | ||
InvalidSecp256k1MessageHashError: () => InvalidSecp256k1MessageHashError, | ||
InvalidSecp256k1PrivateKey: () => InvalidSecp256k1PrivateKey, | ||
InvalidSecp256k1PrivateKeyError: () => InvalidSecp256k1PrivateKeyError, | ||
@@ -172,2 +191,4 @@ InvalidSecp256k1SignatureError: () => InvalidSecp256k1SignatureError, | ||
TransactionNotSignedError: () => TransactionNotSignedError, | ||
UnavailableTransactionField: () => UnavailableTransactionField, | ||
VechainSDKError: () => VechainSDKError, | ||
assert: () => assert, | ||
@@ -178,5 +199,6 @@ assertInnerError: () => assertInnerError, | ||
buildProviderError: () => buildProviderError, | ||
createErrorMessage: () => createErrorMessage, | ||
getEIP1193ErrorCode: () => getEIP1193ErrorCode, | ||
getJSONRPCErrorCode: () => getJSONRPCErrorCode, | ||
stringifyData: () => stringifyData | ||
stringifyData: () => stringifyData2 | ||
}); | ||
@@ -468,2 +490,27 @@ | ||
// src/helpers/helpers.ts | ||
var stringifyData = (data) => { | ||
const getCircularReplacer = () => { | ||
const seen = /* @__PURE__ */ new WeakSet(); | ||
return (_key, value) => { | ||
if (typeof value === "object" && value !== null && _key !== "") { | ||
if (seen.has(value)) { | ||
return; | ||
} | ||
seen.add(value); | ||
} | ||
return value; | ||
}; | ||
}; | ||
return JSON.stringify(data, getCircularReplacer()); | ||
}; | ||
function createErrorMessage(methodName, errorMessage, inputData, innerError) { | ||
return `Method '${methodName}' failed. | ||
-Reason: '${errorMessage}' | ||
-Parameters: | ||
${stringifyData(inputData)} | ||
-Internal error: | ||
${innerError?.message !== void 0 ? innerError.message : "No internal error given"}`; | ||
} | ||
// src/types/errorTypes.ts | ||
@@ -560,3 +607,3 @@ var ERROR_CODES = { | ||
// src/utils/error-message-builder/error-message-builder.ts | ||
var stringifyData = (data) => { | ||
var stringifyData2 = (data) => { | ||
const getCircularReplacer = () => { | ||
@@ -580,3 +627,3 @@ const seen = /* @__PURE__ */ new WeakSet(); | ||
-Parameters: | ||
${stringifyData(inputData)} | ||
${stringifyData2(inputData)} | ||
-Internal error: | ||
@@ -603,3 +650,3 @@ ${innerError?.message !== void 0 ? innerError.message : "No internal error given"}`; | ||
`Inner error is not an instance of Error. Object: | ||
${stringifyData(error)}` | ||
${stringifyData2(error)}` | ||
); | ||
@@ -641,2 +688,50 @@ } | ||
} | ||
// src/available-errors/sdk-error.ts | ||
var VechainSDKError = class extends Error { | ||
constructor(methodName, errorMessage, data, innerError) { | ||
super( | ||
createErrorMessage( | ||
methodName, | ||
errorMessage, | ||
data, | ||
innerError === void 0 ? void 0 : assertInnerError(innerError) | ||
) | ||
); | ||
this.methodName = methodName; | ||
this.errorMessage = errorMessage; | ||
this.data = data; | ||
this.innerError = innerError; | ||
} | ||
}; | ||
// src/available-errors/abi/abi.ts | ||
var InvalidAbiDataToEncodeOrDecode = class extends VechainSDKError { | ||
}; | ||
var InvalidAbiFragment = class extends VechainSDKError { | ||
}; | ||
var InvalidAbiSignatureFormat = class extends VechainSDKError { | ||
}; | ||
// src/available-errors/address/address.ts | ||
var InvalidAddress = class extends VechainSDKError { | ||
}; | ||
// src/available-errors/data/data.ts | ||
var InvalidDataType = class extends VechainSDKError { | ||
}; | ||
// src/available-errors/rlp/rlp.ts | ||
var InvalidRLP = class extends VechainSDKError { | ||
}; | ||
// src/available-errors/secp256k1/secp256k1.ts | ||
var InvalidSecp256k1PrivateKey = class extends VechainSDKError { | ||
}; | ||
var InvalidSecp256k1MessageHash = class extends VechainSDKError { | ||
}; | ||
// src/available-errors/transaction/transaction.ts | ||
var UnavailableTransactionField = class extends VechainSDKError { | ||
}; | ||
// Annotate the CommonJS export names for ESM import in node: | ||
@@ -670,8 +765,13 @@ 0 && (module.exports = { | ||
InvalidAbiDataToEncodeError, | ||
InvalidAbiDataToEncodeOrDecode, | ||
InvalidAbiEventError, | ||
InvalidAbiFormatTypeError, | ||
InvalidAbiFragment, | ||
InvalidAbiFunctionError, | ||
InvalidAbiSignatureFormat, | ||
InvalidAddress, | ||
InvalidAddressError, | ||
InvalidBloomError, | ||
InvalidDataReturnTypeError, | ||
InvalidDataType, | ||
InvalidDataTypeError, | ||
@@ -686,4 +786,7 @@ InvalidHDNodeChaincodeError, | ||
InvalidKeystorePasswordError, | ||
InvalidRLP, | ||
InvalidRLPError, | ||
InvalidSecp256k1MessageHash, | ||
InvalidSecp256k1MessageHashError, | ||
InvalidSecp256k1PrivateKey, | ||
InvalidSecp256k1PrivateKeyError, | ||
@@ -710,2 +813,4 @@ InvalidSecp256k1SignatureError, | ||
TransactionNotSignedError, | ||
UnavailableTransactionField, | ||
VechainSDKError, | ||
assert, | ||
@@ -716,2 +821,3 @@ assertInnerError, | ||
buildProviderError, | ||
createErrorMessage, | ||
errors, | ||
@@ -718,0 +824,0 @@ getEIP1193ErrorCode, |
{ | ||
"name": "@vechain/sdk-errors", | ||
"version": "1.0.0-beta.21", | ||
"version": "1.0.0-beta.22", | ||
"description": "This module is dedicated to managing and customizing errors within the SDK", | ||
@@ -5,0 +5,0 @@ "author": "vechain Foundation", |
export * from './model'; | ||
export * from './helpers'; | ||
export * from './available-errors'; | ||
export * from './types'; | ||
export * from './utils'; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
200149
59
3919