-
Notifications
You must be signed in to change notification settings - Fork 178
/
contracts.go
60 lines (50 loc) · 1.43 KB
/
contracts.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
package errors
import (
"fmt"
"github.com/onflow/flow-go/model/flow"
)
// ContractNotFoundError is returned when an account contract is not found
type ContractNotFoundError struct {
address flow.Address
contract string
}
// NewContractNotFoundError constructs a new ContractNotFoundError
func NewContractNotFoundError(address flow.Address, contract string) error {
return &ContractNotFoundError{
address: address,
contract: contract,
}
}
func (e *ContractNotFoundError) Error() string {
return fmt.Sprintf(
"%s contract %s not found for address %s",
e.Code().String(),
e.contract,
e.address,
)
}
// Code returns the error code for this error type
func (e *ContractNotFoundError) Code() ErrorCode {
return ErrCodeContractNotFoundError
}
// ContractNamesNotFoundError is returned when fetching a list of contract names under an account
type ContractNamesNotFoundError struct {
address flow.Address
}
// NewContractNamesNotFoundError constructs a new ContractNamesNotFoundError
func NewContractNamesNotFoundError(address flow.Address) error {
return &ContractNamesNotFoundError{
address: address,
}
}
func (e *ContractNamesNotFoundError) Error() string {
return fmt.Sprintf(
"%s cannot retrieve current contract names for account %s",
e.Code().String(),
e.address,
)
}
// Code returns the error code for this error type
func (e *ContractNamesNotFoundError) Code() ErrorCode {
return ErrCodeContractNamesNotFoundError
}