This repository has been archived by the owner on Nov 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 30
/
errors.go
62 lines (52 loc) · 1.84 KB
/
errors.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
package types
import (
sdk "github.com/cosmos/cosmos-sdk/types"
)
// CodeType definition
type CodeType = sdk.CodeType
// NFT error code
const (
DefaultCodespace sdk.CodespaceType = ModuleName
CodeInvalidCollection CodeType = 650
CodeUnknownCollection CodeType = 651
CodeInvalidNFT CodeType = 652
CodeUnknownNFT CodeType = 653
CodeNFTAlreadyExists CodeType = 654
CodeEmptyMetadata CodeType = 655
)
// ErrInvalidCollection is an error
func ErrInvalidCollection(codespace sdk.CodespaceType) sdk.Error {
return sdk.NewError(codespace, CodeInvalidCollection, "invalid NFT collection")
}
// ErrUnknownCollection is an error
func ErrUnknownCollection(codespace sdk.CodespaceType, msg string) sdk.Error {
if msg != "" {
return sdk.NewError(codespace, CodeUnknownCollection, msg)
}
return sdk.NewError(codespace, CodeUnknownCollection, "unknown NFT collection")
}
// ErrInvalidNFT is an error
func ErrInvalidNFT(codespace sdk.CodespaceType) sdk.Error {
return sdk.NewError(codespace, CodeInvalidNFT, "invalid NFT")
}
// ErrNFTAlreadyExists is an error when an invalid NFT is minted
func ErrNFTAlreadyExists(codespace sdk.CodespaceType, msg string) sdk.Error {
if msg != "" {
return sdk.NewError(codespace, CodeNFTAlreadyExists, msg)
}
return sdk.NewError(codespace, CodeNFTAlreadyExists, "NFT already exists")
}
// ErrUnknownNFT is an error
func ErrUnknownNFT(codespace sdk.CodespaceType, msg string) sdk.Error {
if msg != "" {
return sdk.NewError(codespace, CodeUnknownNFT, msg)
}
return sdk.NewError(codespace, CodeUnknownNFT, "unknown NFT")
}
// ErrEmptyMetadata is an error when metadata is empty
func ErrEmptyMetadata(codespace sdk.CodespaceType, msg string) sdk.Error {
if msg != "" {
return sdk.NewError(codespace, CodeEmptyMetadata, msg)
}
return sdk.NewError(codespace, CodeEmptyMetadata, "NFT metadata can't be empty")
}