-
Notifications
You must be signed in to change notification settings - Fork 46
/
errors.go
79 lines (73 loc) · 2.98 KB
/
errors.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package core
import "errors"
// ErrorCode is code for RSocket error.
type ErrorCode uint32
func (e ErrorCode) String() string {
switch e {
case ErrorCodeInvalidSetup:
return "INVALID_SETUP"
case ErrorCodeUnsupportedSetup:
return "UNSUPPORTED_SETUP"
case ErrorCodeRejectedSetup:
return "REJECTED_SETUP"
case ErrorCodeRejectedResume:
return "REJECTED_RESUME"
case ErrorCodeConnectionError:
return "CONNECTION_ERROR"
case ErrorCodeConnectionClose:
return "CONNECTION_CLOSE"
case ErrorCodeApplicationError:
return "APPLICATION_ERROR"
case ErrorCodeRejected:
return "REJECTED"
case ErrorCodeCanceled:
return "CANCELED"
case ErrorCodeInvalid:
return "INVALID"
default:
return "UNKNOWN"
}
}
const (
// ErrorCodeInvalidSetup means the setup frame is invalid for the server.
ErrorCodeInvalidSetup ErrorCode = 0x00000001
// ErrorCodeUnsupportedSetup means some (or all) of the parameters specified by the client are unsupported by the server.
ErrorCodeUnsupportedSetup ErrorCode = 0x00000002
// ErrorCodeRejectedSetup means server rejected the setup, it can specify the reason in the payload.
ErrorCodeRejectedSetup ErrorCode = 0x00000003
// ErrorCodeRejectedResume means server rejected the resume, it can specify the reason in the payload.
ErrorCodeRejectedResume ErrorCode = 0x00000004
// ErrorCodeConnectionError means the connection is being terminated.
ErrorCodeConnectionError ErrorCode = 0x00000101
// ErrorCodeConnectionClose means the connection is being terminated.
ErrorCodeConnectionClose ErrorCode = 0x00000102
// ErrorCodeApplicationError means application layer logic generating a Reactive Streams onError event.
ErrorCodeApplicationError ErrorCode = 0x00000201
// ErrorCodeRejected means Responder reject it.
ErrorCodeRejected ErrorCode = 0x00000202
// ErrorCodeCanceled means the Responder canceled the request but may have started processing it (similar to REJECTED but doesn't guarantee lack of side-effects).
ErrorCodeCanceled ErrorCode = 0x00000203
// ErrorCodeInvalid means the request is invalid.
ErrorCodeInvalid ErrorCode = 0x00000204
)
// CustomError provides a method of accessing code and data.
type CustomError interface {
error
// ErrorCode returns error code.
ErrorCode() ErrorCode
// ErrorData returns error data bytes.
ErrorData() []byte
}
// Error defines.
var (
ErrFrameLengthExceed = errors.New("rsocket: frame length is greater than 24bits")
ErrInvalidTransport = errors.New("rsocket: invalid Transport")
ErrInvalidFrame = errors.New("rsocket: invalid frame")
ErrInvalidContext = errors.New("rsocket: invalid context")
ErrInvalidFrameLength = errors.New("rsocket: invalid frame length")
ErrReleasedResource = errors.New("rsocket: resource has been released")
ErrInvalidEmitter = errors.New("rsocket: invalid emitter")
ErrHandlerNil = errors.New("rsocket: handler cannot be nil")
ErrHandlerExist = errors.New("rsocket: handler exists already")
ErrSendFull = errors.New("rsocket: frame send channel is full")
)