Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a generic "nats" error #1172

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
99 changes: 50 additions & 49 deletions nats.go
Expand Up @@ -90,55 +90,56 @@ const (

// Errors
var (
ErrConnectionClosed = errors.New("nats: connection closed")
ErrConnectionDraining = errors.New("nats: connection draining")
ErrDrainTimeout = errors.New("nats: draining connection timed out")
ErrConnectionReconnecting = errors.New("nats: connection reconnecting")
ErrSecureConnRequired = errors.New("nats: secure connection required")
ErrSecureConnWanted = errors.New("nats: secure connection not available")
ErrBadSubscription = errors.New("nats: invalid subscription")
ErrTypeSubscription = errors.New("nats: invalid subscription type")
ErrBadSubject = errors.New("nats: invalid subject")
ErrBadQueueName = errors.New("nats: invalid queue name")
ErrSlowConsumer = errors.New("nats: slow consumer, messages dropped")
ErrTimeout = errors.New("nats: timeout")
ErrBadTimeout = errors.New("nats: timeout invalid")
ErrAuthorization = errors.New("nats: authorization violation")
ErrAuthExpired = errors.New("nats: authentication expired")
ErrAuthRevoked = errors.New("nats: authentication revoked")
ErrAccountAuthExpired = errors.New("nats: account authentication expired")
ErrNoServers = errors.New("nats: no servers available for connection")
ErrJsonParse = errors.New("nats: connect message, json parse error")
ErrChanArg = errors.New("nats: argument needs to be a channel type")
ErrMaxPayload = errors.New("nats: maximum payload exceeded")
ErrMaxMessages = errors.New("nats: maximum messages delivered")
ErrSyncSubRequired = errors.New("nats: illegal call on an async subscription")
ErrMultipleTLSConfigs = errors.New("nats: multiple tls.Configs not allowed")
ErrNoInfoReceived = errors.New("nats: protocol exception, INFO not received")
ErrReconnectBufExceeded = errors.New("nats: outbound buffer limit exceeded")
ErrInvalidConnection = errors.New("nats: invalid connection")
ErrInvalidMsg = errors.New("nats: invalid message or message nil")
ErrInvalidArg = errors.New("nats: invalid argument")
ErrInvalidContext = errors.New("nats: invalid context")
ErrNoDeadlineContext = errors.New("nats: context requires a deadline")
ErrNoEchoNotSupported = errors.New("nats: no echo option not supported by this server")
ErrClientIDNotSupported = errors.New("nats: client ID not supported by this server")
ErrUserButNoSigCB = errors.New("nats: user callback defined without a signature handler")
ErrNkeyButNoSigCB = errors.New("nats: nkey defined without a signature handler")
ErrNoUserCB = errors.New("nats: user callback not defined")
ErrNkeyAndUser = errors.New("nats: user callback and nkey defined")
ErrNkeysNotSupported = errors.New("nats: nkeys not supported by the server")
ErrStaleConnection = errors.New("nats: " + STALE_CONNECTION)
ErrTokenAlreadySet = errors.New("nats: token and token handler both set")
ErrMsgNotBound = errors.New("nats: message is not bound to subscription/connection")
ErrMsgNoReply = errors.New("nats: message does not have a reply")
ErrClientIPNotSupported = errors.New("nats: client IP not supported by this server")
ErrDisconnected = errors.New("nats: server is disconnected")
ErrHeadersNotSupported = errors.New("nats: headers not supported by this server")
ErrBadHeaderMsg = errors.New("nats: message could not decode headers")
ErrNoResponders = errors.New("nats: no responders available for request")
ErrMaxConnectionsExceeded = errors.New("nats: server maximum connections exceeded")
ErrConnectionNotTLS = errors.New("nats: connection is not tls")
ErrNats = errors.New("nats")
ErrConnectionClosed = fmt.Errorf("%w: connection closed", ErrNats)
ErrConnectionDraining = fmt.Errorf("%w: connection draining", ErrNats)
ErrDrainTimeout = fmt.Errorf("%w: draining connection timed out", ErrNats)
ErrConnectionReconnecting = fmt.Errorf("%w: connection reconnecting", ErrNats)
ErrSecureConnRequired = fmt.Errorf("%w: secure connection required", ErrNats)
ErrSecureConnWanted = fmt.Errorf("%w: secure connection not available", ErrNats)
ErrBadSubscription = fmt.Errorf("%w: invalid subscription", ErrNats)
ErrTypeSubscription = fmt.Errorf("%w: invalid subscription type", ErrNats)
ErrBadSubject = fmt.Errorf("%w: invalid subject", ErrNats)
ErrBadQueueName = fmt.Errorf("%w: invalid queue name", ErrNats)
ErrSlowConsumer = fmt.Errorf("%w: slow consumer, messages dropped", ErrNats)
ErrTimeout = fmt.Errorf("%w: timeout", ErrNats)
ErrBadTimeout = fmt.Errorf("%w: timeout invalid", ErrNats)
ErrAuthorization = fmt.Errorf("%w: authorization violation", ErrNats)
ErrAuthExpired = fmt.Errorf("%w: authentication expired", ErrNats)
ErrAuthRevoked = fmt.Errorf("%w: authentication revoked", ErrNats)
ErrAccountAuthExpired = fmt.Errorf("%w: account authentication expired", ErrNats)
ErrNoServers = fmt.Errorf("%w: no servers available for connection", ErrNats)
ErrJsonParse = fmt.Errorf("%w: connect message, json parse error", ErrNats)
ErrChanArg = fmt.Errorf("%w: argument needs to be a channel type", ErrNats)
ErrMaxPayload = fmt.Errorf("%w: maximum payload exceeded", ErrNats)
ErrMaxMessages = fmt.Errorf("%w: maximum messages delivered", ErrNats)
ErrSyncSubRequired = fmt.Errorf("%w: illegal call on an async subscription", ErrNats)
ErrMultipleTLSConfigs = fmt.Errorf("%w: multiple tls.Configs not allowed", ErrNats)
ErrNoInfoReceived = fmt.Errorf("%w: protocol exception, INFO not received", ErrNats)
ErrReconnectBufExceeded = fmt.Errorf("%w: outbound buffer limit exceeded", ErrNats)
ErrInvalidConnection = fmt.Errorf("%w: invalid connection", ErrNats)
ErrInvalidMsg = fmt.Errorf("%w: invalid message or message nil", ErrNats)
ErrInvalidArg = fmt.Errorf("%w: invalid argument", ErrNats)
ErrInvalidContext = fmt.Errorf("%w: invalid context", ErrNats)
ErrNoDeadlineContext = fmt.Errorf("%w: context requires a deadline", ErrNats)
ErrNoEchoNotSupported = fmt.Errorf("%w: no echo option not supported by this server", ErrNats)
ErrClientIDNotSupported = fmt.Errorf("%w: client ID not supported by this server", ErrNats)
ErrUserButNoSigCB = fmt.Errorf("%w: user callback defined without a signature handler", ErrNats)
ErrNkeyButNoSigCB = fmt.Errorf("%w: nkey defined without a signature handler", ErrNats)
ErrNoUserCB = fmt.Errorf("%w: user callback not defined", ErrNats)
ErrNkeyAndUser = fmt.Errorf("%w: user callback and nkey defined", ErrNats)
ErrNkeysNotSupported = fmt.Errorf("%w: nkeys not supported by the server", ErrNats)
ErrStaleConnection = fmt.Errorf("%w: "+STALE_CONNECTION, ErrNats)
ErrTokenAlreadySet = fmt.Errorf("%w: token and token handler both set", ErrNats)
ErrMsgNotBound = fmt.Errorf("%w: message is not bound to subscription/connection", ErrNats)
ErrMsgNoReply = fmt.Errorf("%w: message does not have a reply", ErrNats)
ErrClientIPNotSupported = fmt.Errorf("%w: client IP not supported by this server", ErrNats)
ErrDisconnected = fmt.Errorf("%w: server is disconnected", ErrNats)
ErrHeadersNotSupported = fmt.Errorf("%w: headers not supported by this server", ErrNats)
ErrBadHeaderMsg = fmt.Errorf("%w: message could not decode headers", ErrNats)
ErrNoResponders = fmt.Errorf("%w: no responders available for request", ErrNats)
ErrMaxConnectionsExceeded = fmt.Errorf("%w: server maximum connections exceeded", ErrNats)
ErrConnectionNotTLS = fmt.Errorf("%w: connection is not tls", ErrNats)
)

func init() {
Expand Down