diff --git a/src/errors.ts b/src/errors.ts index 094f391..7181160 100644 --- a/src/errors.ts +++ b/src/errors.ts @@ -1,9 +1,9 @@ import { JsonRpcError, EthereumProviderError } from './classes'; import { errorCodes } from './error-constants'; -import type { DataWithOptionalCause } from './utils'; +import type { DataWithOptionalCause, OptionalDataWithOptionalCause } from './utils'; import { getMessageFromCode } from './utils'; -type EthereumErrorOptions = { +type EthereumErrorOptions = { message?: string; data?: Data; }; @@ -15,7 +15,7 @@ type ServerErrorOptions = { type CustomErrorArg = ServerErrorOptions; -type JsonRpcErrorsArg = +type JsonRpcErrorsArg = | EthereumErrorOptions | string; @@ -65,7 +65,7 @@ export const rpcErrors = { * @param arg - The error message or options bag. * @returns An instance of the {@link JsonRpcError} class. */ - internal: ( + internal: ( arg?: JsonRpcErrorsArg, ) => getJsonRpcError(errorCodes.rpc.internal, arg), @@ -245,7 +245,7 @@ export const providerErrors = { * @param arg - The error message or options bag. * @returns An instance of the {@link JsonRpcError} class. */ -function getJsonRpcError( +function getJsonRpcError( code: number, arg?: JsonRpcErrorsArg, ): JsonRpcError { @@ -278,7 +278,7 @@ function getEthProviderError( * @param arg - The error message or options bag. * @returns A tuple containing the error message and optional data. */ -function parseOpts( +function parseOpts( arg?: JsonRpcErrorsArg, ): [message?: string | undefined, data?: Data | undefined] { if (arg) {