3 ms·
These error codes are too vague to pinpoint a problem, and too vague to even really point in the direction of a problem. I'd prefer some mechanism for making a
by londons_explore 5y ago
These error codes are too vague to pinpoint a problem, and too vague to even really point in the direction of a problem.
I'd prefer some mechanism for making a cross-program shortened stack trace indicating the specific error (ie. 'no space on device') and the sequence of things in progress that have now all failed (ie. 'cannot create output file', 'cannot decompress files', 'cannot install XYZ package', 'cannot update system').
Then it's very clear to the user - The system can't be updated because XYZ package couldn't be installed, because files couldn't be decompressed, because the output file couldn't be created, because there is no space left.
- mikepurvis 5y agoI think the main value here is understanding at the broadest level whether the problem is internal to the problem (unforeseen logic error), with how I configured the program (bad flags), or with the environment in which I ran the program (out of memory, disk, whatever). Obviously a single integer is not going to be a rich error-reporting mechanism, but particularly in the context of something like a process manager or job runner, it could be helpful to know what kinds of errors might go away on a retry, for example.
- ttyprintk 5y agoI think history supports this, but I’m not sure I can cite a reference. Early Unix code I wrote followed the convention that codes 1-3 belong to system utilities, 4-9 are unreserved, and users pick 10-127. Some exotic use cases wrap some meaning into higher codes, but historically we only cared to detect whether the error comes from system binaries or within the application. I suppose programming on top of the application would mean using 20, but I still pick 10 by habit.
- Ono-Sendai 5y agoYou can do this in a simple enough way, in C++: each software level catches the exception from the level below, prepends its own message string to it and then throws a new exception with the combined message.
- londons_explore 5y agoThere also needs to be a way to get strings from a subprocess. Most unix-y tools involve a lot of subprocesses, and the ultimate failure might be 3 processes away...
- kevin_thibedeau 5y agoRAM is exhausted. Now what happens?
- londons_explore 5y agoEven the standard libraries of most programming languages don't have defined behaviour in out-of-memory conditions. Instead just use paging, pushing out cache, or memory compression to have a soft limit to ensure you never need to handle out of memory. In today's world of delayed page allocation, you'll probably just get killed with SIGBUS anyway.
- Ono-Sendai 5y agoAt that point you're probably screwed anyway.