-
Notifications
You must be signed in to change notification settings - Fork 0
/
returnCodes.go
73 lines (58 loc) · 1.99 KB
/
returnCodes.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package vmcommon
import "fmt"
// ReturnCode is an enum with the possible error codes returned by the VM
type ReturnCode int
func (rc ReturnCode) String() string {
switch rc {
case Ok:
return "ok"
case FunctionNotFound:
return "function not found"
case FunctionWrongSignature:
return "wrong signature for function"
case ContractNotFound:
return "contract not found"
case UserError:
return "user error"
case OutOfGas:
return "out of gas"
case AccountCollision:
return "account collision"
case OutOfFunds:
return "out of funds"
case CallStackOverFlow:
return "call stack overflow"
case ContractInvalid:
return "contract invalid"
case ExecutionFailed:
return "execution failed"
default:
return fmt.Sprintf("unknown error, code: %d", rc)
}
}
const (
// Ok is returned when execution was completed normally.
Ok ReturnCode = 0
// FunctionNotFound is returned when the input specifies a function name that does not exist or is not public.
FunctionNotFound ReturnCode = 1
// FunctionWrongSignature is returned when the wrong number of arguments is provided.
FunctionWrongSignature ReturnCode = 2
// ContractNotFound is returned when the called contract does not exist.
ContractNotFound ReturnCode = 3
// UserError is returned for various execution errors.
UserError ReturnCode = 4
// OutOfGas is returned when VM execution runs out of gas.
OutOfGas ReturnCode = 5
// AccountCollision is returned when created account already exists.
AccountCollision ReturnCode = 6
// OutOfFunds is returned when the caller (sender) runs out of funds.
OutOfFunds ReturnCode = 7
// CallStackOverFlow is returned when stack overflow occurs.
CallStackOverFlow ReturnCode = 8
// ContractInvalid is returned when the contract is invalid.
ContractInvalid ReturnCode = 9
// ExecutionFailed is returned when the execution of the specified function has failed.
ExecutionFailed ReturnCode = 10
// UpgradeFailed is returned when the upgrade of the contract has failed
UpgradeFailed ReturnCode = 11
)