@@ -44,7 +44,10 @@ impl Error {
44
44
45
45
pub ( crate ) fn pool_cleared_error ( address : & StreamAddress ) -> Self {
46
46
ErrorKind :: ConnectionPoolClearedError {
47
- message : format ! ( "Conneciton pool for {} cleared during operation execution" , address)
47
+ message : format ! (
48
+ "Conneciton pool for {} cleared during operation execution" ,
49
+ address
50
+ ) ,
48
51
}
49
52
. into ( )
50
53
}
@@ -129,10 +132,13 @@ impl Error {
129
132
130
133
/// Whether an error originated from the server.
131
134
pub ( crate ) fn is_server_error ( & self ) -> bool {
132
- matches ! ( self . kind. as_ref( ) , ErrorKind :: AuthenticationError { .. }
133
- | ErrorKind :: BulkWriteError ( _)
134
- | ErrorKind :: CommandError ( _)
135
- | ErrorKind :: WriteError ( _) )
135
+ matches ! (
136
+ self . kind. as_ref( ) ,
137
+ ErrorKind :: AuthenticationError { .. }
138
+ | ErrorKind :: BulkWriteError ( _)
139
+ | ErrorKind :: CommandError ( _)
140
+ | ErrorKind :: WriteError ( _)
141
+ )
136
142
}
137
143
138
144
/// Returns the labels for this error.
@@ -153,7 +159,9 @@ impl Error {
153
159
154
160
/// Whether this error contains the specified label.
155
161
pub fn contains_label < T : AsRef < str > > ( & self , label : T ) -> bool {
156
- self . labels ( ) . iter ( ) . any ( |actual_label| actual_label. as_str ( ) == label. as_ref ( ) )
162
+ self . labels ( )
163
+ . iter ( )
164
+ . any ( |actual_label| actual_label. as_str ( ) == label. as_ref ( ) )
157
165
}
158
166
159
167
/// Returns a copy of this Error with the specified label added.
@@ -373,7 +381,10 @@ impl ErrorKind {
373
381
}
374
382
375
383
pub ( crate ) fn is_network_error ( & self ) -> bool {
376
- matches ! ( self , ErrorKind :: Io ( ..) | ErrorKind :: ConnectionPoolClearedError { .. } )
384
+ matches ! (
385
+ self ,
386
+ ErrorKind :: Io ( ..) | ErrorKind :: ConnectionPoolClearedError { .. }
387
+ )
377
388
}
378
389
379
390
/// Gets the code/message tuple from this error, if applicable. In the case of write errors, the
@@ -397,13 +408,14 @@ impl ErrorKind {
397
408
pub ( crate ) fn code_name ( & self ) -> Option < & str > {
398
409
match self {
399
410
ErrorKind :: CommandError ( ref cmd_err) => Some ( cmd_err. code_name . as_str ( ) ) ,
400
- ErrorKind :: WriteError ( ref failure) => {
401
- match failure {
402
- WriteFailure :: WriteConcernError ( ref wce) => Some ( wce. code_name . as_str ( ) ) ,
403
- WriteFailure :: WriteError ( ref we) => we. code_name . as_deref ( ) ,
404
- }
405
- }
406
- ErrorKind :: BulkWriteError ( ref bwe) => bwe. write_concern_error . as_ref ( ) . map ( |wce| wce. code_name . as_str ( ) ) ,
411
+ ErrorKind :: WriteError ( ref failure) => match failure {
412
+ WriteFailure :: WriteConcernError ( ref wce) => Some ( wce. code_name . as_str ( ) ) ,
413
+ WriteFailure :: WriteError ( ref we) => we. code_name . as_deref ( ) ,
414
+ } ,
415
+ ErrorKind :: BulkWriteError ( ref bwe) => bwe
416
+ . write_concern_error
417
+ . as_ref ( )
418
+ . map ( |wce| wce. code_name . as_str ( ) ) ,
407
419
_ => None ,
408
420
}
409
421
}
@@ -564,8 +576,8 @@ pub enum WriteFailure {
564
576
/// An error that occurred due to not being able to satisfy a write concern.
565
577
WriteConcernError ( WriteConcernError ) ,
566
578
567
- /// An error that occurred during a write operation that wasn't due to being unable to satisfy a
568
- /// write concern.
579
+ /// An error that occurred during a write operation that wasn't due to being unable to satisfy
580
+ /// a write concern.
569
581
WriteError ( WriteError ) ,
570
582
}
571
583
0 commit comments