2018-08-09 01:06:34 +00:00
|
|
|
package types
|
|
|
|
|
|
|
|
import (
|
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
|
|
)
|
|
|
|
|
2018-11-28 22:19:22 +00:00
|
|
|
// Ethermint error codes
|
2018-08-09 01:06:34 +00:00
|
|
|
const (
|
2018-11-28 22:19:22 +00:00
|
|
|
// DefaultCodespace reserves a Codespace for Ethermint.
|
|
|
|
DefaultCodespace sdk.CodespaceType = "ethermint"
|
2018-08-09 01:06:34 +00:00
|
|
|
|
2018-11-28 22:19:22 +00:00
|
|
|
CodeInvalidValue sdk.CodeType = 1
|
|
|
|
CodeInvalidAccountNumber sdk.CodeType = 2
|
2018-08-09 01:06:34 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func codeToDefaultMsg(code sdk.CodeType) string {
|
|
|
|
switch code {
|
2018-11-28 22:19:22 +00:00
|
|
|
case CodeInvalidValue:
|
|
|
|
return "invalid value"
|
|
|
|
case CodeInvalidAccountNumber:
|
|
|
|
return "invalid account number"
|
2018-08-09 01:06:34 +00:00
|
|
|
default:
|
|
|
|
return sdk.CodeToDefaultMsg(code)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-28 22:19:22 +00:00
|
|
|
// ErrInvalidValue returns a standardized SDK error resulting from an invalid
|
|
|
|
// value.
|
|
|
|
func ErrInvalidValue(msg string) sdk.Error {
|
|
|
|
return sdk.NewError(DefaultCodespace, CodeInvalidValue, msg)
|
|
|
|
}
|
|
|
|
|
|
|
|
// ErrInvalidAccountNumber returns a standardized SDK error resulting from an
|
|
|
|
// invalid account number.
|
|
|
|
func ErrInvalidAccountNumber(msg string) sdk.Error {
|
|
|
|
return sdk.NewError(DefaultCodespace, CodeInvalidAccountNumber, msg)
|
2018-08-09 01:06:34 +00:00
|
|
|
}
|