As 0 is a boolean false and 1 a true, shouldn't APIs in HTTP return response_code 0 for Success instead of a 1?
3 Answers
There can be many reasons for an error and a parent process will often know what specifically went wrong with a child process. As such 0 is used for success and 1 to 255 provides flexibility for failure reason(s).
For example a child process could return:
1File not found2User not authorized3File locked by another process4Connection not active5Configuration incomplete6Process cancelled by user
etc, etc.
Indicating errors as non-zero integers is in conformance with POSIX standard, aka conformance with Unix Standard, in particular with Error Numbers defined by library. This article, for instance, provides a good overview of the exit statuses. Therefore, whatever HTTP server processes we're discussing, they should strive to adhere to this standard if it expects to be portable across multiple systems, including Ubuntu, and yes - provide 0 on success. If we're talking about responses from an HTTP server ro a client, then API should conform to using HTTP status codes
3These numbers represents error, i.e. if there's is an error it is set to any positive number (1-255) and if there's no error it is set to 0.