CloseStatus is a convenience wrapper around Go 1.13's errors.As to grab the status code from a CloseError. -1 will be returned if the passed error is nil or not a CloseError.
(err error)
| 76 | // |
| 77 | // -1 will be returned if the passed error is nil or not a CloseError. |
| 78 | func CloseStatus(err error) StatusCode { |
| 79 | var ce CloseError |
| 80 | if errors.As(err, &ce) { |
| 81 | return ce.Code |
| 82 | } |
| 83 | return -1 |
| 84 | } |
| 85 | |
| 86 | // Close performs the WebSocket close handshake with the given status code and reason. |
| 87 | // |
no outgoing calls
searching dependent graphs…