26
26
//
27
27
//===----------------------------------------------------------------------===//
28
28
29
- public protocol NIOMPLEXError : Equatable , Error { }
29
+ public protocol NIOMPLEXError : Equatable , Error { }
30
30
31
- public enum MuxerError : Error {
31
+ public enum MuxerError : Error {
32
32
case custom( String )
33
33
}
34
34
35
35
/// Errors that NIO raises when handling MPLEX connections.
36
36
public enum NIOMPLEXErrors {
37
37
38
38
public static func noSuchStream( streamID: MPLEXStreamID , file: String = #file, line: UInt = #line) -> NoSuchStream {
39
- return NoSuchStream ( streamID: streamID, file: file, line: line)
39
+ NoSuchStream ( streamID: streamID, file: file, line: line)
40
40
}
41
-
42
- public static func streamClosed( streamID: MPLEXStreamID , errorCode: MPLEXErrorCode , file: String = #file, line: UInt = #line) -> StreamClosed {
43
- return StreamClosed ( streamID: streamID, errorCode: errorCode, file: file, line: line)
41
+
42
+ public static func streamClosed(
43
+ streamID: MPLEXStreamID ,
44
+ errorCode: MPLEXErrorCode ,
45
+ file: String = #file,
46
+ line: UInt = #line
47
+ ) -> StreamClosed {
48
+ StreamClosed ( streamID: streamID, errorCode: errorCode, file: file, line: line)
44
49
}
45
-
50
+
46
51
public static func noStreamIDAvailable( file: String = #file, line: UInt = #line) -> NoStreamIDAvailable {
47
- return NoStreamIDAvailable ( file: file, line: line)
52
+ NoStreamIDAvailable ( file: file, line: line)
48
53
}
49
54
50
55
public static func streamError( streamID: MPLEXStreamID , baseError: Error ) -> StreamError {
51
- return StreamError ( streamID: streamID, baseError: baseError)
56
+ StreamError ( streamID: streamID, baseError: baseError)
52
57
}
53
58
54
59
/// An attempt was made to issue a write on a stream that does not exist.
@@ -69,8 +74,8 @@ public enum NIOMPLEXErrors {
69
74
self . location = _location ( file: file, line: line)
70
75
}
71
76
72
- public static func == ( lhs: NoSuchStream , rhs: NoSuchStream ) -> Bool {
73
- return lhs. streamID == rhs. streamID
77
+ public static func == ( lhs: NoSuchStream , rhs: NoSuchStream ) -> Bool {
78
+ lhs. streamID == rhs. streamID
74
79
}
75
80
}
76
81
@@ -96,8 +101,8 @@ public enum NIOMPLEXErrors {
96
101
self . location = _location ( file: file, line: line)
97
102
}
98
103
99
- public static func == ( lhs: StreamClosed , rhs: StreamClosed ) -> Bool {
100
- return lhs. streamID == rhs. streamID && lhs. errorCode == rhs. errorCode
104
+ public static func == ( lhs: StreamClosed , rhs: StreamClosed ) -> Bool {
105
+ lhs. streamID == rhs. streamID && lhs. errorCode == rhs. errorCode
101
106
}
102
107
}
103
108
@@ -108,7 +113,7 @@ public enum NIOMPLEXErrors {
108
113
109
114
/// The location where the error was thrown.
110
115
public var location : String {
111
- return _location ( file: self . file, line: self . line)
116
+ _location ( file: self . file, line: self . line)
112
117
}
113
118
114
119
@available ( * , deprecated, renamed: " noStreamIDAvailable " )
@@ -121,8 +126,8 @@ public enum NIOMPLEXErrors {
121
126
self . line = line
122
127
}
123
128
124
- public static func == ( lhs: NoStreamIDAvailable , rhs: NoStreamIDAvailable ) -> Bool {
125
- return true
129
+ public static func == ( lhs: NoStreamIDAvailable , rhs: NoStreamIDAvailable ) -> Bool {
130
+ true
126
131
}
127
132
}
128
133
@@ -143,7 +148,7 @@ public enum NIOMPLEXErrors {
143
148
}
144
149
145
150
func copy( ) -> Storage {
146
- return Storage (
151
+ Storage (
147
152
streamID: self . streamID,
148
153
baseError: self . baseError
149
154
)
@@ -160,7 +165,7 @@ public enum NIOMPLEXErrors {
160
165
161
166
public var baseError : Error {
162
167
get {
163
- return self . storage. baseError
168
+ self . storage. baseError
164
169
}
165
170
set {
166
171
self . copyStorageIfNotUniquelyReferenced ( )
@@ -170,7 +175,7 @@ public enum NIOMPLEXErrors {
170
175
171
176
public var streamID : MPLEXStreamID {
172
177
get {
173
- return self . storage. streamID
178
+ self . storage. streamID
174
179
}
175
180
set {
176
181
self . copyStorageIfNotUniquelyReferenced ( )
@@ -179,7 +184,7 @@ public enum NIOMPLEXErrors {
179
184
}
180
185
181
186
public var description : String {
182
- return " StreamError(streamID: \( self . streamID) , baseError: \( self . baseError) ) "
187
+ " StreamError(streamID: \( self . streamID) , baseError: \( self . baseError) ) "
183
188
}
184
189
185
190
fileprivate init ( streamID: MPLEXStreamID , baseError: Error ) {
@@ -188,7 +193,6 @@ public enum NIOMPLEXErrors {
188
193
}
189
194
}
190
195
191
-
192
196
/// This enum covers errors that are thrown internally for messaging reasons. These should
193
197
/// not leak.
194
198
internal enum InternalError : Error {
@@ -197,10 +201,10 @@ internal enum InternalError: Error {
197
201
case codecError( code: MPLEXErrorCode )
198
202
}
199
203
200
- extension InternalError : Hashable { }
204
+ extension InternalError : Hashable { }
201
205
202
206
private func _location( file: String , line: UInt ) -> String {
203
- return " \( file) : \( line) "
207
+ " \( file) : \( line) "
204
208
}
205
209
206
210
private final class StringAndLocationStorage : Equatable {
@@ -209,7 +213,7 @@ private final class StringAndLocationStorage: Equatable {
209
213
var line : UInt
210
214
211
215
var location : String {
212
- return _location ( file: self . file, line: self . line)
216
+ _location ( file: self . file, line: self . line)
213
217
}
214
218
215
219
init ( _ value: String , file: String , line: UInt ) {
@@ -219,11 +223,11 @@ private final class StringAndLocationStorage: Equatable {
219
223
}
220
224
221
225
func copy( ) -> StringAndLocationStorage {
222
- return StringAndLocationStorage ( self . value, file: self . file, line: self . line)
226
+ StringAndLocationStorage ( self . value, file: self . file, line: self . line)
223
227
}
224
228
225
- static func == ( lhs: StringAndLocationStorage , rhs: StringAndLocationStorage ) -> Bool {
229
+ static func == ( lhs: StringAndLocationStorage , rhs: StringAndLocationStorage ) -> Bool {
226
230
// Only compare the value. The 'file' is not relevant here.
227
- return lhs. value == rhs. value
231
+ lhs. value == rhs. value
228
232
}
229
233
}
0 commit comments