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