@@ -38,19 +38,11 @@ impl AsyncPingable for Bedrock {
38
38
39
39
// Attempt to extract useful information from the payload.
40
40
BedrockResponse :: extract ( & payload) . map_or_else (
41
- || {
42
- Err ( Error :: IoError ( io:: Error :: new (
43
- io:: ErrorKind :: Other ,
44
- "Invalid Payload" ,
45
- ) ) )
46
- } ,
41
+ || Err ( Error :: IoError ( io:: Error :: other ( "Invalid Payload" ) ) ) ,
47
42
|response| Ok ( ( latency, response) ) ,
48
43
)
49
44
} else {
50
- Err ( Error :: IoError ( io:: Error :: new (
51
- io:: ErrorKind :: Other ,
52
- "Invalid Packet Response" ,
53
- ) ) )
45
+ Err ( Error :: IoError ( io:: Error :: other ( "Invalid Packet Response" ) ) )
54
46
}
55
47
}
56
48
}
@@ -64,8 +56,7 @@ trait AsyncReadBedrockExt: AsyncRead + AsyncReadExt + Unpin {
64
56
let len = self . read_u16 ( ) . await ?;
65
57
let mut buf = vec ! [ 0 ; len as usize ] ;
66
58
self . read_exact ( & mut buf) . await ?;
67
- String :: from_utf8 ( buf)
68
- . map_err ( |_| io:: Error :: new ( io:: ErrorKind :: Other , "Invalid UTF-8 String." ) )
59
+ String :: from_utf8 ( buf) . map_err ( |_| io:: Error :: other ( "Invalid UTF-8 String." ) )
69
60
}
70
61
}
71
62
@@ -126,10 +117,7 @@ impl Connection {
126
117
self . socket . send ( & buf) . await ?;
127
118
}
128
119
Packet :: UnconnectedPong { .. } => {
129
- return Err ( io:: Error :: new (
130
- io:: ErrorKind :: Other ,
131
- "Invalid C -> S Packet" ,
132
- ) ) ;
120
+ return Err ( io:: Error :: other ( "Invalid C -> S Packet" ) ) ;
133
121
}
134
122
}
135
123
@@ -152,8 +140,7 @@ impl Connection {
152
140
buf. read_exact ( & mut tmp) . await ?;
153
141
154
142
if tmp != OFFLINE_MESSAGE_DATA_ID {
155
- return Err ( io:: Error :: new (
156
- io:: ErrorKind :: Other ,
143
+ return Err ( io:: Error :: other (
157
144
"incorrect offline message data ID received" ,
158
145
) ) ;
159
146
}
@@ -166,10 +153,7 @@ impl Connection {
166
153
payload,
167
154
} )
168
155
}
169
- _ => Err ( io:: Error :: new (
170
- io:: ErrorKind :: Other ,
171
- "Invalid S -> C Packet" ,
172
- ) ) ,
156
+ _ => Err ( io:: Error :: other ( "Invalid S -> C Packet" ) ) ,
173
157
}
174
158
}
175
159
}
0 commit comments