Currently when authentication fails (e.g. in db.auth() in the shell), the error that comes back does not have an error code, just a description. It is a common auditing policy by enterprises to log how many times someone tries to log-in and not having an error code for this makes it harder to identify. Especially as other DB products have error codes, it makes Mongo a special case.
Providing error codes is a separate JIRA issue but specifically for this error would help in the short-term and make Mongo easier to integrate with.