Skip to content

Commit

Permalink
util: introduce new temp error with unset error code
Browse files Browse the repository at this point in the history
  • Loading branch information
jochem-brouwer committed Feb 24, 2025
1 parent aa3702b commit a8cd9e1
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions packages/util/src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ export type EthereumJSErrorObject = {
type: EthereumJSErrorMetaData
}

// In order to update all our errors to use `EthereumJSError`, temporarily include the
// unset error code. All errors throwing this code should be updated to use the relevant
// error code.
export const UNSET_ERROR_CODE = 'ETHEREUMJS_UNSET_ERROR_CODE'

/**
* Generic EthereumJS error with attached metadata
*/
Expand Down Expand Up @@ -41,6 +46,18 @@ export class EthereumJSError<T extends { code: string }> extends Error {
}
}

/**
* @deprecated Use `EthereumJSError` with a set error code instead
* @param message Optional error message
* @param stack Optional stack trace
* @returns
*/
export function EthereumJSErrorUnsetCode(message?: string, stack?: string) {
return new EthereumJSError({ code: UNSET_ERROR_CODE }, message, stack)
}

// Below here: specific monorepo-wide errors

export enum UsageErrorType {
UNSUPPORTED_FEATURE = 'unsupported feature',
}
Expand Down

0 comments on commit a8cd9e1

Please sign in to comment.