@@ -114,7 +114,7 @@ impl AuthMechanism {
114
114
match self {
115
115
AuthMechanism :: ScramSha1 | AuthMechanism :: ScramSha256 => {
116
116
if credential. username . is_none ( ) {
117
- return Err ( ErrorKind :: ArgumentError {
117
+ return Err ( ErrorKind :: InvalidArgument {
118
118
message : "No username provided for SCRAM authentication" . to_string ( ) ,
119
119
}
120
120
. into ( ) ) ;
@@ -123,14 +123,14 @@ impl AuthMechanism {
123
123
}
124
124
AuthMechanism :: MongoDbX509 => {
125
125
if credential. password . is_some ( ) {
126
- return Err ( ErrorKind :: ArgumentError {
126
+ return Err ( ErrorKind :: InvalidArgument {
127
127
message : "A password cannot be specified with MONGODB-X509" . to_string ( ) ,
128
128
}
129
129
. into ( ) ) ;
130
130
}
131
131
132
132
if credential. source . as_deref ( ) . unwrap_or ( "$external" ) != "$external" {
133
- return Err ( ErrorKind :: ArgumentError {
133
+ return Err ( ErrorKind :: InvalidArgument {
134
134
message : "only $external may be specified as an auth source for \
135
135
MONGODB-X509"
136
136
. to_string ( ) ,
@@ -142,21 +142,21 @@ impl AuthMechanism {
142
142
}
143
143
AuthMechanism :: Plain => {
144
144
if credential. username . is_none ( ) {
145
- return Err ( ErrorKind :: ArgumentError {
145
+ return Err ( ErrorKind :: InvalidArgument {
146
146
message : "No username provided for PLAIN authentication" . to_string ( ) ,
147
147
}
148
148
. into ( ) ) ;
149
149
}
150
150
151
151
if credential. username . as_deref ( ) == Some ( "" ) {
152
- return Err ( ErrorKind :: ArgumentError {
152
+ return Err ( ErrorKind :: InvalidArgument {
153
153
message : "Username for PLAIN authentication must be non-empty" . to_string ( ) ,
154
154
}
155
155
. into ( ) ) ;
156
156
}
157
157
158
158
if credential. password . is_none ( ) {
159
- return Err ( ErrorKind :: ArgumentError {
159
+ return Err ( ErrorKind :: InvalidArgument {
160
160
message : "No password provided for PLAIN authentication" . to_string ( ) ,
161
161
}
162
162
. into ( ) ) ;
@@ -167,7 +167,7 @@ impl AuthMechanism {
167
167
#[ cfg( feature = "tokio-runtime" ) ]
168
168
AuthMechanism :: MongoDbAws => {
169
169
if credential. username . is_some ( ) && credential. password . is_none ( ) {
170
- return Err ( ErrorKind :: ArgumentError {
170
+ return Err ( ErrorKind :: InvalidArgument {
171
171
message : "Username cannot be provided without password for MONGODB-AWS \
172
172
authentication"
173
173
. to_string ( ) ,
@@ -235,13 +235,13 @@ impl AuthMechanism {
235
235
Self :: Plain => Ok ( None ) ,
236
236
#[ cfg( feature = "tokio-runtime" ) ]
237
237
AuthMechanism :: MongoDbAws => Ok ( None ) ,
238
- AuthMechanism :: MongoDbCr => Err ( ErrorKind :: AuthenticationError {
238
+ AuthMechanism :: MongoDbCr => Err ( ErrorKind :: Authentication {
239
239
message : "MONGODB-CR is deprecated and not supported by this driver. Use SCRAM \
240
240
for password-based authentication instead"
241
241
. into ( ) ,
242
242
}
243
243
. into ( ) ) ,
244
- _ => Err ( ErrorKind :: AuthenticationError {
244
+ _ => Err ( ErrorKind :: Authentication {
245
245
message : format ! ( "Authentication mechanism {:?} not yet implemented." , self ) ,
246
246
}
247
247
. into ( ) ) ,
@@ -278,13 +278,13 @@ impl AuthMechanism {
278
278
AuthMechanism :: MongoDbAws => {
279
279
aws:: authenticate_stream ( stream, credential, server_api, http_client) . await
280
280
}
281
- AuthMechanism :: MongoDbCr => Err ( ErrorKind :: AuthenticationError {
281
+ AuthMechanism :: MongoDbCr => Err ( ErrorKind :: Authentication {
282
282
message : "MONGODB-CR is deprecated and not supported by this driver. Use SCRAM \
283
283
for password-based authentication instead"
284
284
. into ( ) ,
285
285
}
286
286
. into ( ) ) ,
287
- _ => Err ( ErrorKind :: AuthenticationError {
287
+ _ => Err ( ErrorKind :: Authentication {
288
288
message : format ! ( "Authentication mechanism {:?} not yet implemented." , self ) ,
289
289
}
290
290
. into ( ) ) ,
@@ -307,12 +307,12 @@ impl FromStr for AuthMechanism {
307
307
#[ cfg( feature = "tokio-runtime" ) ]
308
308
MONGODB_AWS_STR => Ok ( AuthMechanism :: MongoDbAws ) ,
309
309
#[ cfg( not( feature = "tokio-runtime" ) ) ]
310
- MONGODB_AWS_STR => Err ( ErrorKind :: ArgumentError {
310
+ MONGODB_AWS_STR => Err ( ErrorKind :: InvalidArgument {
311
311
message : "MONGODB-AWS auth is only supported with the tokio runtime" . into ( ) ,
312
312
}
313
313
. into ( ) ) ,
314
314
315
- _ => Err ( ErrorKind :: ArgumentError {
315
+ _ => Err ( ErrorKind :: InvalidArgument {
316
316
message : format ! ( "invalid mechanism string: {}" , str ) ,
317
317
}
318
318
. into ( ) ) ,
0 commit comments