@vechain/sdk-errors
Advanced tools
Comparing version 1.0.0-beta.3 to 1.0.0-beta.4
@@ -568,10 +568,16 @@ /** | ||
/** | ||
* Build error object according to the error code provided. | ||
* The error code determines the error type returned and the data type to be provided. | ||
* @param methodName - The method name where the error was thrown. | ||
* @param code - The error code from the error types enum. | ||
* @param message - The error message. | ||
* @param data - The error data. | ||
* @param innerError - The inner error. | ||
* @returns the error object. | ||
* Builds an error object with the error code provided and specified parameters. | ||
* | ||
* @param {string} methodName - The name of the method where the error occurred. | ||
* @param {ErrorCodeT} code - The error code. | ||
* @param {string} message - The error message. | ||
* @param {DataTypeT} [data] - Additional data associated with the error. | ||
* @param {unknown} [innerError] - An inner error associated with the error. | ||
* | ||
* @returns {ErrorType<ErrorCodeT>} - The error object. | ||
* | ||
* @throws {Error} - If the error code is invalid. | ||
* | ||
* @remarks | ||
* **IMPORTANT: no sensitive data should be passed as any parameter.** | ||
*/ | ||
@@ -581,11 +587,12 @@ declare function buildError<ErrorCodeT extends ErrorCode, DataTypeT extends DataType<ErrorCodeT>>(methodName: string, code: ErrorCodeT, message: string, data?: DataTypeT, innerError?: unknown): ErrorType<ErrorCodeT>; | ||
/** | ||
* Build RPC error object according to the error code provided. | ||
* Builds a ProviderRpcError object with the given code, message, and data, | ||
* according [Rpc Errors](https://eips.ethereum.org/EIPS/eip-1193#rpc-errors) | ||
* | ||
* @link [Rpc Errors](https://eips.ethereum.org/EIPS/eip-1193#rpc-errors) | ||
* @param {EIP1193 | JSONRPC} code - The error code. | ||
* @param {string} message - The error message. | ||
* @param {DataTypeT} [data] - Optional data associated with the error. | ||
* @return {ProviderRpcError} - The constructed ProviderRpcError object. | ||
* | ||
* @param code - The error code as specified in EIP-1193 or EIP-1474 | ||
* @param message - The error message | ||
* @param data - Contains optional extra information about the error | ||
* | ||
* @returns the error object | ||
* @remarks | ||
* **IMPORTANT: no sensitive data should be passed as any parameter.** | ||
*/ | ||
@@ -604,9 +611,13 @@ declare function buildProviderError<ErrorCodeT extends ErrorCode, DataTypeT extends DataType<ErrorCodeT>>(code: EIP1193 | JSONRPC, message: string, data?: DataTypeT): ProviderRpcError; | ||
/** | ||
* Function to build an error message | ||
* Builds an error message with the specified method name, error message, input data, and optional inner error. | ||
* | ||
* @param methodName - The method name where the error was thrown. | ||
* @param errorMessage - The error message. | ||
* @param inputData - The input data. | ||
* @param innerError - The inner error. | ||
* @returns The error message string. | ||
* @param {string} methodName - The name of the method that failed. | ||
* @param {string} errorMessage - The specific reason for the failure. | ||
* @param {DataType} inputData - The input data used by the method. | ||
* @param {Error} [innerError] - An optional inner error that caused the failure. | ||
* | ||
* @return {string} - The built error message. | ||
* | ||
* @remarks | ||
* **IMPORTANT: no sensitive data should be passed as any parameter.** | ||
*/ | ||
@@ -616,16 +627,29 @@ declare function buildErrorMessage<ErrorCodeT extends ErrorCode, DataTypeT extends DataType<ErrorCodeT>>(methodName: string, errorMessage: string, inputData: DataTypeT, innerError?: Error): string; | ||
/** | ||
* Assert that the condition is true, otherwise throw an error. | ||
* Asserts that a given condition is true. If the condition is false, an error is thrown. | ||
* | ||
* @param methodName - The method name where the error was thrown. | ||
* @param condition - The condition to be asserted. | ||
* @param code - The error code from the error types enum. | ||
* @param message - The error message. | ||
* @param data - The error data. | ||
* @param innerError - The inner error. | ||
* @param {string} methodName - The name of the method or function being asserted. | ||
* @param {boolean} condition - The condition to be asserted. | ||
* @param {ErrorCode} code - The error code to be associated with the error if the condition is false. | ||
* @param {string} message - The error message to be associated with the error if the condition is false. | ||
* @param {DataType} [data] - Additional data to be associated with the error if the condition is false. | ||
* @param {unknown} [innerError] - The inner error to be associated with the error if the condition is false. | ||
* | ||
* @returns {void} | ||
* | ||
* @throws {Error} An error object if the condition is false. | ||
* | ||
* @remarks | ||
* **IMPORTANT: no sensitive data should be passed as any parameter.** | ||
*/ | ||
declare function assert<ErrorCodeT extends ErrorCode, DataTypeT extends DataType<ErrorCodeT>>(methodName: string, condition: boolean, code: ErrorCodeT, message: string, data?: DataTypeT, innerError?: unknown): void; | ||
/** | ||
* Assert that the inner error object is an instance of Error | ||
* @param error an unknown object to be asserted as an instance of Error | ||
* @returns an Error object | ||
* Asserts that the given error is an instance of the Error class. | ||
* If the error is an instance of Error, it is returned. | ||
* If the error is not an instance of Error, a new Error object is created with a descriptive message. | ||
* | ||
* @param {unknown} error - The error to be asserted. | ||
* @return {Error} - The error if it is an instance of Error, or a new Error object if it is not. | ||
* | ||
* @remarks | ||
* **IMPORTANT: no sensitive data should be passed as any parameter.** | ||
*/ | ||
@@ -632,0 +656,0 @@ declare function assertInnerError(error: unknown): Error; |
{ | ||
"name": "@vechain/sdk-errors", | ||
"version": "1.0.0-beta.3", | ||
"version": "1.0.0-beta.4", | ||
"description": "This module is dedicated to managing and customizing errors within the SDK", | ||
@@ -5,0 +5,0 @@ "author": "vechain Foundation", |
@@ -6,10 +6,17 @@ import { type DataType, type ErrorCode, type ErrorType } from '../../types'; | ||
/** | ||
* Assert that the condition is true, otherwise throw an error. | ||
* Asserts that a given condition is true. If the condition is false, an error is thrown. | ||
* | ||
* @param methodName - The method name where the error was thrown. | ||
* @param condition - The condition to be asserted. | ||
* @param code - The error code from the error types enum. | ||
* @param message - The error message. | ||
* @param data - The error data. | ||
* @param innerError - The inner error. | ||
* @param {string} methodName - The name of the method or function being asserted. | ||
* @param {boolean} condition - The condition to be asserted. | ||
* @param {ErrorCode} code - The error code to be associated with the error if the condition is false. | ||
* @param {string} message - The error message to be associated with the error if the condition is false. | ||
* @param {DataType} [data] - Additional data to be associated with the error if the condition is false. | ||
* @param {unknown} [innerError] - The inner error to be associated with the error if the condition is false. | ||
* | ||
* @returns {void} | ||
* | ||
* @throws {Error} An error object if the condition is false. | ||
* | ||
* @remarks | ||
* **IMPORTANT: no sensitive data should be passed as any parameter.** | ||
*/ | ||
@@ -40,5 +47,11 @@ function assert< | ||
/** | ||
* Assert that the inner error object is an instance of Error | ||
* @param error an unknown object to be asserted as an instance of Error | ||
* @returns an Error object | ||
* Asserts that the given error is an instance of the Error class. | ||
* If the error is an instance of Error, it is returned. | ||
* If the error is not an instance of Error, a new Error object is created with a descriptive message. | ||
* | ||
* @param {unknown} error - The error to be asserted. | ||
* @return {Error} - The error if it is an instance of Error, or a new Error object if it is not. | ||
* | ||
* @remarks | ||
* **IMPORTANT: no sensitive data should be passed as any parameter.** | ||
*/ | ||
@@ -45,0 +58,0 @@ function assertInnerError(error: unknown): Error { |
@@ -11,10 +11,16 @@ import { | ||
/** | ||
* Build error object according to the error code provided. | ||
* The error code determines the error type returned and the data type to be provided. | ||
* @param methodName - The method name where the error was thrown. | ||
* @param code - The error code from the error types enum. | ||
* @param message - The error message. | ||
* @param data - The error data. | ||
* @param innerError - The inner error. | ||
* @returns the error object. | ||
* Builds an error object with the error code provided and specified parameters. | ||
* | ||
* @param {string} methodName - The name of the method where the error occurred. | ||
* @param {ErrorCodeT} code - The error code. | ||
* @param {string} message - The error message. | ||
* @param {DataTypeT} [data] - Additional data associated with the error. | ||
* @param {unknown} [innerError] - An inner error associated with the error. | ||
* | ||
* @returns {ErrorType<ErrorCodeT>} - The error object. | ||
* | ||
* @throws {Error} - If the error code is invalid. | ||
* | ||
* @remarks | ||
* **IMPORTANT: no sensitive data should be passed as any parameter.** | ||
*/ | ||
@@ -21,0 +27,0 @@ function buildError< |
@@ -11,11 +11,12 @@ import { | ||
/** | ||
* Build RPC error object according to the error code provided. | ||
* Builds a ProviderRpcError object with the given code, message, and data, | ||
* according [Rpc Errors](https://eips.ethereum.org/EIPS/eip-1193#rpc-errors) | ||
* | ||
* @link [Rpc Errors](https://eips.ethereum.org/EIPS/eip-1193#rpc-errors) | ||
* @param {EIP1193 | JSONRPC} code - The error code. | ||
* @param {string} message - The error message. | ||
* @param {DataTypeT} [data] - Optional data associated with the error. | ||
* @return {ProviderRpcError} - The constructed ProviderRpcError object. | ||
* | ||
* @param code - The error code as specified in EIP-1193 or EIP-1474 | ||
* @param message - The error message | ||
* @param data - Contains optional extra information about the error | ||
* | ||
* @returns the error object | ||
* @remarks | ||
* **IMPORTANT: no sensitive data should be passed as any parameter.** | ||
*/ | ||
@@ -44,5 +45,7 @@ function buildProviderError< | ||
/** | ||
* Check if the code is an EIP1193 code | ||
* @param code - The code to be checked | ||
* @returns true if the code is an EIP1193 code | ||
* Checks if the given code is EIP1193 code. | ||
* | ||
* @param {EIP1193 | JSONRPC} code - The code to check. | ||
* | ||
* @return {boolean} - True if the code is an instance of EIP1193, otherwise false. | ||
*/ | ||
@@ -49,0 +52,0 @@ function isEIP1193Code(code: EIP1193 | JSONRPC): code is EIP1193 { |
@@ -36,9 +36,13 @@ import type { DataType, ErrorCode } from '../../types'; | ||
/** | ||
* Function to build an error message | ||
* Builds an error message with the specified method name, error message, input data, and optional inner error. | ||
* | ||
* @param methodName - The method name where the error was thrown. | ||
* @param errorMessage - The error message. | ||
* @param inputData - The input data. | ||
* @param innerError - The inner error. | ||
* @returns The error message string. | ||
* @param {string} methodName - The name of the method that failed. | ||
* @param {string} errorMessage - The specific reason for the failure. | ||
* @param {DataType} inputData - The input data used by the method. | ||
* @param {Error} [innerError] - An optional inner error that caused the failure. | ||
* | ||
* @return {string} - The built error message. | ||
* | ||
* @remarks | ||
* **IMPORTANT: no sensitive data should be passed as any parameter.** | ||
*/ | ||
@@ -45,0 +49,0 @@ function buildErrorMessage< |
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
175306
3401