Search code examples
ldaphttp-status-code-404http-status-code-401http-errorerror-code

Are the http error codes in decimal format or hex?


Python ldap library throws exceptions with hex error codes like 52e for invalid credentials and 532 for password expired. Now I need to decide in what format (hex or dec) should I relay this information to End-User.

It begs to my original question, what format do HTTP Servers use for communicating error codes like 401, 404 and etc. Alternatively, I could ask that is 404 that translates to Not Found a decimal number or a hex number?


Solution

  • HTTP codes are always represented as decimal integers.

    The authentication error codes that you're seeing are not from the python LDAP library, they are from Windows. While they are presented in hex, they are sometimes represented in decimal format also. You can see this in the list of Windows System Error Codes.

    I would argue that you should not present the numerical error codes to the user at all. Translate it to a sentence that explains the reason for the login failure.