Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support registering errors from another package #22

Merged
merged 1 commit into from
Oct 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 59 additions & 7 deletions fhevm/errors.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,63 @@
package fhevm

import (
"errors"
)

// List of EVM execution errors needed by the fhEVM.
// TODO: initialize errors from erros passed by users. That would make fhevm-go errors match the EVM environment's errors.
// List of EVM execution errors needed by the fhEVM
var (
ErrExecutionReverted = errors.New("execution reverted")
ErrOutOfGas error
ErrCodeStoreOutOfGas error
ErrDepth error
ErrInsufficientBalance error
ErrContractAddressCollision error
ErrExecutionReverted error
ErrMaxInitCodeSizeExceeded error
ErrMaxCodeSizeExceeded error
ErrInvalidJump error
ErrWriteProtection error
ErrReturnDataOutOfBounds error
ErrGasUintOverflow error
ErrInvalidCode error
ErrNonceUintOverflow error
ErrAddrProhibited error
ErrInvalidCoinbase error
ErrSenderAddressNotAllowListed error
)

// Register package errors with other custom errors.
//
// This is useful in cases where returned errors need to be recognized by the framework
// using fhevm-go, without much code changes in the framework.
func RegisterErrors(
outOfGasError error,
codeStoreOutOfGasError error,
depthError error,
insufficientBalanceError error,
contractAddressCollisionError error,
executionRevertedError error,
maxInitCodeSizeExceededError error,
maxCodeSizeExceededError error,
invalidJumpError error,
writeProtectionError error,
returnDataOutOfBoundsError error,
gasUintOverflowError error,
invalidCodeError error,
nonceUintOverflowError error,
addrProhibitedError error,
invalidCoinbaseError error,
senderAddressNotAllowListedError error) {
ErrOutOfGas = outOfGasError
ErrCodeStoreOutOfGas = codeStoreOutOfGasError
ErrDepth = depthError
ErrInsufficientBalance = insufficientBalanceError
ErrContractAddressCollision = contractAddressCollisionError
ErrExecutionReverted = executionRevertedError
ErrMaxInitCodeSizeExceeded = maxInitCodeSizeExceededError
ErrMaxCodeSizeExceeded = maxCodeSizeExceededError
ErrInvalidJump = invalidJumpError
ErrWriteProtection = writeProtectionError
ErrReturnDataOutOfBounds = returnDataOutOfBoundsError
ErrGasUintOverflow = gasUintOverflowError
ErrInvalidCode = invalidCodeError
ErrNonceUintOverflow = nonceUintOverflowError
ErrAddrProhibited = addrProhibitedError
ErrInvalidCoinbase = invalidCoinbaseError
ErrSenderAddressNotAllowListed = senderAddressNotAllowListedError
}