I need to standardize on how I classify and handle errors/exceptions 'gracefully'.
I currently use a process by which I report the errors to a function passing an error-number, severity-code, location-info and extra-info-string. This function returns boolean true if the error is fatal and the app should die, false otherwise. As part of it's process, apart from visual-feedback to the user, the function also log-to-file errors of above some severity-level.
Error-number indexes an array of strings explaining the type of error, e.g.:'File access','User Input','Thread-creation','Network access', etc. Severity-code is binary OR of 0,1,2 or 4, 0=informative, 1=user_retry, 2=cannot_complete, 4=cannot_continue. Location-info is module & function, and Extra-info is parameter- and local variable values.
I want to make this into a standard way of error-handling that I can put in a library and re-use in all my apps. I mainly use C/C++ on Linux, but would want to use the resultant library with other languages/platforms as well.
An idea is to extend the error-type array to indicate some default behavior for a given severity-level, but should this then become the action taken and give no options to the user?
Or: should such extension be a sub-array of options that the user need to pick from? The problem with this is that the options would of necessity be generalized programming-related options that may very-well completely baffle an end-user.
Or: should each app that uses the error-lib routine pass along its own array of either errors or default behaviors - but this will defeat the purpose of the library...
Or: should the severity-levels be handled in each app?
Or: what do you suggest? How do you handle errors? How can I improve this?