-
Notifications
You must be signed in to change notification settings - Fork 751
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Util, Block: added generic error types like ValidationError, UsageError
- Loading branch information
1 parent
95b6b8b
commit 88e6a31
Showing
3 changed files
with
41 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,29 @@ | ||
import { EthereumJSError } from '@ethereumjs/util' | ||
import { UsageError, ValidationError } from '@ethereumjs/util' | ||
|
||
export enum HeaderValidationErrorCode { | ||
/** | ||
* Always define error codes on the generic Util | ||
* error class level (e.g. associated to `ValidationError`) | ||
*/ | ||
export enum ValidationErrorCode { | ||
WRONG_TX_TRIE_LENGTH = 'WRONG_TX_TRIE_LENGTH', | ||
} | ||
|
||
/** | ||
* Additional types extending the generic Util | ||
* error types (e.g. `ValidationErrorType`) | ||
*/ | ||
export type HeaderValidationErrorType = { | ||
block: string | ||
received: string | ||
} | ||
export type HeaderUsageErrorType = { | ||
block: string | ||
} | ||
|
||
export class HeaderValidationError extends EthereumJSError<HeaderValidationErrorType> {} | ||
/** | ||
* Dedicated error classes for the specific package, | ||
* always to be subclassed from the generic Util error type | ||
* classes (e.g. `ValidationError`, not: `EthereumJSError`) | ||
*/ | ||
export class HeaderValidationError extends ValidationError<HeaderValidationErrorType> {} | ||
export class HeaderUsageError extends UsageError<HeaderUsageErrorType> {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters