Skip to content

Commit

Permalink
Merge pull request #276 from CosmWasm/proper-create-error
Browse files Browse the repository at this point in the history
Increment x/wasm error codes by 1
  • Loading branch information
ethanfrey authored Oct 6, 2020
2 parents b0add1f + d4e39aa commit c761a7f
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions x/wasm/internal/types/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,45 +8,47 @@ import (
var (
DefaultCodespace = ModuleName

// Note: never use code 1 for any errors - that is reserved for ErrInternal in the core cosmos sdk

// ErrCreateFailed error for wasm code that has already been uploaded or failed
ErrCreateFailed = sdkErrors.Register(DefaultCodespace, 1, "create wasm contract failed")
ErrCreateFailed = sdkErrors.Register(DefaultCodespace, 2, "create wasm contract failed")

// ErrAccountExists error for a contract account that already exists
ErrAccountExists = sdkErrors.Register(DefaultCodespace, 2, "contract account already exists")
ErrAccountExists = sdkErrors.Register(DefaultCodespace, 3, "contract account already exists")

// ErrInstantiateFailed error for rust instantiate contract failure
ErrInstantiateFailed = sdkErrors.Register(DefaultCodespace, 3, "instantiate wasm contract failed")
ErrInstantiateFailed = sdkErrors.Register(DefaultCodespace, 4, "instantiate wasm contract failed")

// ErrExecuteFailed error for rust execution contract failure
ErrExecuteFailed = sdkErrors.Register(DefaultCodespace, 4, "execute wasm contract failed")
ErrExecuteFailed = sdkErrors.Register(DefaultCodespace, 5, "execute wasm contract failed")

// ErrGasLimit error for out of gas
ErrGasLimit = sdkErrors.Register(DefaultCodespace, 5, "insufficient gas")
ErrGasLimit = sdkErrors.Register(DefaultCodespace, 6, "insufficient gas")

// ErrInvalidGenesis error for invalid genesis file syntax
ErrInvalidGenesis = sdkErrors.Register(DefaultCodespace, 6, "invalid genesis")
ErrInvalidGenesis = sdkErrors.Register(DefaultCodespace, 7, "invalid genesis")

// ErrNotFound error for an entry not found in the store
ErrNotFound = sdkErrors.Register(DefaultCodespace, 7, "not found")
ErrNotFound = sdkErrors.Register(DefaultCodespace, 8, "not found")

// ErrQueryFailed error for rust smart query contract failure
ErrQueryFailed = sdkErrors.Register(DefaultCodespace, 8, "query wasm contract failed")
ErrQueryFailed = sdkErrors.Register(DefaultCodespace, 9, "query wasm contract failed")

// ErrInvalidMsg error when we cannot process the error returned from the contract
ErrInvalidMsg = sdkErrors.Register(DefaultCodespace, 9, "invalid CosmosMsg from the contract")
ErrInvalidMsg = sdkErrors.Register(DefaultCodespace, 10, "invalid CosmosMsg from the contract")

// ErrMigrationFailed error for rust execution contract failure
ErrMigrationFailed = sdkErrors.Register(DefaultCodespace, 10, "migrate wasm contract failed")
ErrMigrationFailed = sdkErrors.Register(DefaultCodespace, 11, "migrate wasm contract failed")

// ErrEmpty error for empty content
ErrEmpty = sdkErrors.Register(DefaultCodespace, 11, "empty")
ErrEmpty = sdkErrors.Register(DefaultCodespace, 12, "empty")

// ErrLimit error for content that exceeds a limit
ErrLimit = sdkErrors.Register(DefaultCodespace, 12, "exceeds limit")
ErrLimit = sdkErrors.Register(DefaultCodespace, 13, "exceeds limit")

// ErrInvalid error for content that is invalid in this context
ErrInvalid = sdkErrors.Register(DefaultCodespace, 13, "invalid")
ErrInvalid = sdkErrors.Register(DefaultCodespace, 14, "invalid")

// ErrDuplicate error for content that exsists
ErrDuplicate = sdkErrors.Register(DefaultCodespace, 14, "duplicate")
ErrDuplicate = sdkErrors.Register(DefaultCodespace, 15, "duplicate")
)

0 comments on commit c761a7f

Please sign in to comment.