Skip to content

Commit fa00474

Browse files
committed
Merge branch 'CDRIVER-1961-improve-gssapi-error-message'
* CDRIVER-1961-improve-gssapi-error-message: CDRIVER-1961 Improve error message when GSSAPI module not available
2 parents 318883f + caf92a3 commit fa00474

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/mongoc/mongoc-sasl.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,12 +235,24 @@ _mongoc_sasl_is_failure (int status, bson_error_t *error)
235235
status,
236236
"SASL Failure: insufficient memory.");
237237
break;
238-
case SASL_NOMECH:
238+
case SASL_NOMECH: {
239+
bson_string_t *str = bson_string_new ("available mechanisms: ");
240+
const char **mechs = sasl_global_listmech ();
241+
int i = 0;
242+
243+
for (i = 0; mechs[i]; i++) {
244+
bson_string_append (str, mechs[i]);
245+
if (mechs[i + 1]) {
246+
bson_string_append (str, ",");
247+
}
248+
}
239249
bson_set_error (error,
240250
MONGOC_ERROR_SASL,
241251
status,
242-
"SASL Failure: failure to negotiate mechanism");
243-
break;
252+
"SASL Failure: failure to negotiate mechanism (%s)",
253+
str->str);
254+
bson_string_free (str, 0);
255+
} break;
244256
case SASL_BADPARAM:
245257
bson_set_error (error,
246258
MONGOC_ERROR_SASL,

0 commit comments

Comments
 (0)