MCPcopy
hub / github.com/nats-io/nats.go / processErr

Method processErr

nats.go:4181–4213  ·  view source on GitHub ↗

processErr processes any error messages from the server and sets the connection's LastError.

(ie string)

Source from the content-addressed store, hash-verified

4179// processErr processes any error messages from the server and
4180// sets the connection's LastError.
4181func (nc *Conn) processErr(ie string) {
4182 // Trim, remove quotes
4183 ne := normalizeErr(ie)
4184 // convert to lower case.
4185 e := strings.ToLower(ne)
4186
4187 var close bool
4188
4189 // FIXME(dlc) - process Slow Consumer signals special.
4190 if e == STALE_CONNECTION {
4191 close = nc.processOpErr(ErrStaleConnection, false)
4192 } else if e == MAX_CONNECTIONS_ERR {
4193 close = nc.processOpErr(ErrMaxConnectionsExceeded, false)
4194 } else if e == MAX_ACCOUNT_CONNECTIONS_ERR {
4195 close = nc.processOpErr(ErrMaxAccountConnectionsExceeded, false)
4196 } else if strings.HasPrefix(e, PERMISSIONS_ERR) {
4197 nc.processTransientError(fmt.Errorf("%w: %s", ErrPermissionViolation, ne))
4198 } else if strings.HasPrefix(e, MAX_SUBSCRIPTIONS_ERR) {
4199 nc.processTransientError(ErrMaxSubscriptionsExceeded)
4200 } else if authErr := checkAuthError(e); authErr != nil {
4201 nc.mu.Lock()
4202 close = nc.processAuthError(authErr)
4203 nc.mu.Unlock()
4204 } else {
4205 close = true
4206 nc.mu.Lock()
4207 nc.err = errors.New("nats: " + ne)
4208 nc.mu.Unlock()
4209 }
4210 if close {
4211 nc.close(CLOSED, true, nil)
4212 }
4213}
4214
4215// kickFlusher will send a bool on a channel to kick the
4216// flush Go routine to flush data to the server.

Callers 1

parseMethod · 0.95

Calls 7

processOpErrMethod · 0.95
processTransientErrorMethod · 0.95
processAuthErrorMethod · 0.95
closeMethod · 0.95
normalizeErrFunction · 0.85
checkAuthErrorFunction · 0.85
ErrorfMethod · 0.80

Tested by

no test coverage detected