github.com/decred/dcrlnd@v0.7.6/watchtower/wtwire/error_code.go (about) 1 package wtwire 2 3 import "fmt" 4 5 // ErrorCode represents a generic error code used when replying to watchtower 6 // clients. Specific reply messages may extend the ErrorCode primitive and add 7 // custom codes, so long as they don't collide with the generic error codes.. 8 type ErrorCode uint16 9 10 const ( 11 // CodeOK signals that the request was successfully processed by the 12 // watchtower. 13 CodeOK ErrorCode = 0 14 15 // CodeTemporaryFailure alerts the client that the watchtower is 16 // temporarily unavailable, but that it may try again at a later time. 17 CodeTemporaryFailure ErrorCode = 40 18 19 // CodePermanentFailure alerts the client that the watchtower has 20 // permanently failed, and further communication should be avoided. 21 CodePermanentFailure ErrorCode = 50 22 ) 23 24 // String returns a human-readable description of an ErrorCode. 25 func (c ErrorCode) String() string { 26 switch c { 27 case CodeOK: 28 return "CodeOK" 29 case CodeTemporaryFailure: 30 return "CodeTemporaryFailure" 31 case CodePermanentFailure: 32 return "CodePermanentFailure" 33 case CreateSessionCodeAlreadyExists: 34 return "CreateSessionCodeAlreadyExists" 35 case CreateSessionCodeRejectMaxUpdates: 36 return "CreateSessionCodeRejectMaxUpdates" 37 case CreateSessionCodeRejectRewardRate: 38 return "CreateSessionCodeRejectRewardRate" 39 case CreateSessionCodeRejectSweepFeeRate: 40 return "CreateSessionCodeRejectSweepFeeRate" 41 case CreateSessionCodeRejectBlobType: 42 return "CreateSessionCodeRejectBlobType" 43 case StateUpdateCodeClientBehind: 44 return "StateUpdateCodeClientBehind" 45 case StateUpdateCodeMaxUpdatesExceeded: 46 return "StateUpdateCodeMaxUpdatesExceeded" 47 case StateUpdateCodeSeqNumOutOfOrder: 48 return "StateUpdateCodeSeqNumOutOfOrder" 49 case DeleteSessionCodeNotFound: 50 return "DeleteSessionCodeNotFound" 51 default: 52 return fmt.Sprintf("UnknownErrorCode: %d", c) 53 } 54 }