errors.gno
3.07 Kb · 64 lines
1package core
2
3import (
4 "errors"
5 "strings"
6)
7
8// Error messages are defined as constants rather than package-level error
9// values; build them with makeError at the call site (see above).
10const (
11 ErrClientNotActive = "client is not active"
12 ErrInvalidConnectionState = "invalid connection state"
13 ErrInvalidChannelState = "invalid channel state"
14 ErrInvalidCounterpartyChannelId = "invalid counterparty channel id"
15 ErrSyncAckEmpty = "sync ack cannot be empty"
16 ErrUnknownPacketStatus = "unknown packet status"
17 ErrUnauthorizedAckWriter = "caller not authorized to write ack"
18 ErrAcknowledgementAlreadyWritten = "acknowledgement already written"
19 ErrAcknowledgementEmpty = "acknowledgement cannot be empty"
20 ErrAcknowledgementMismatch = "acknowledgement mismatch"
21 ErrUnauthorizedPacketSender = "caller not authorized to send packet"
22 ErrTimeoutMustBeSet = "timeout must be set"
23 ErrPacketCommitmentAlreadyExists = "packet commitment already exists"
24 ErrPacketCommitmentNotFound = "packet commitment not found"
25 ErrPacketCombinedDataTooLarge = "packet combined data too large"
26 ErrPacketAlreadyAcknowledged = "packet already acknowledged"
27 ErrPacketReceiptNotFound = "packet receipt not found"
28 ErrNotEnoughPackets = "not enough packets"
29 ErrBatchSameChannelOnly = "batch must use the same channel"
30 ErrAcknowledgementCountMismatch = "acknowledgement count mismatch"
31 ErrTimeoutProofTimestampNotFound = "packet timeout proof timestamp not found"
32 ErrPortAlreadyRegistered = "port already registered"
33 ErrBatchPacketsNotFound = "batch packets not found"
34 ErrBatchReceiptsNotFound = "batch receipts not found"
35 ErrPacketAlreadyReceived = "packet already received"
36 ErrPacketTimeoutExpired = "packet timeout expired"
37 ErrPacketTimeoutNotReached = "packet timeout not reached"
38 ErrIntentNotSupported = "intent receive not supported"
39
40 // Value-carrying "not found" base messages. The missing id/port is appended
41 // as a second makeError argument at the call site, e.g.
42 // makeError(ErrChannelNotFound, id.String()).
43 ErrPortNotFound = "port not found"
44
45 // Query getters return these when the requested state is missing. Getters
46 // return an error rather than panicking so callers can decide how to handle
47 // a missing lookup.
48 ErrClientNotFound = "client not found"
49 ErrClientStateNotFound = "client state not found"
50 ErrConsensusStateNotFound = "consensus state not found"
51 ErrConnectionNotFound = "connection not found"
52 ErrChannelNotFound = "channel not found"
53 ErrMembershipProofNotFound = "membership proof not found"
54
55 // ErrSpoofedRealm guards non-crossing (_ int, rlm realm, ...) entrypoints:
56 // the passed rlm must be the current crossing frame, not a forged or stale
57 // token replayed by a caller.
58 ErrSpoofedRealm = "rlm does not match the current crossing frame"
59 ErrNotProxyRealm = "rlm is not proxy realm"
60)
61
62func makeError(msgs ...string) error {
63 return errors.New(strings.Join(msgs, ", "))
64}