forked from hyperledger-archives/burrow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vm.go
55 lines (46 loc) · 1.3 KB
/
vm.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
package errors
import (
"bytes"
"fmt"
"github.com/hyperledger/burrow/crypto"
"github.com/hyperledger/burrow/permission"
)
type PermissionDenied struct {
Address crypto.Address
Perm permission.PermFlag
}
func (err PermissionDenied) ErrorCode() Code {
return ErrorCodePermissionDenied
}
func (err PermissionDenied) Error() string {
return fmt.Sprintf("Account/contract %v does not have permission %v", err.Address, err.Perm)
}
type NestedCallError struct {
CodedError
Caller crypto.Address
Callee crypto.Address
StackDepth uint64
}
func (err NestedCallError) Error() string {
return fmt.Sprintf("error in nested call at depth %v: %s (callee) -> %s (caller): %v",
err.StackDepth, err.Callee, err.Caller, err.CodedError)
}
type CallError struct {
// The error from the original call which defines the overall error code
CodedError
// Errors from nested sub-calls of the original call that may have also occurred
NestedErrors []NestedCallError
}
func (err CallError) Error() string {
buf := new(bytes.Buffer)
buf.WriteString("Call error: ")
buf.WriteString(err.CodedError.Error())
if len(err.NestedErrors) > 0 {
buf.WriteString(", nested call errors:\n")
for _, nestedErr := range err.NestedErrors {
buf.WriteString(nestedErr.Error())
buf.WriteByte('\n')
}
}
return buf.String()
}