Use directory of files for error content or error templates.
Currently all internal errors are fixed structure and generated on demand.
The current error layout is a JSON dictionary
{
"Error": "some error message"
}
The current issues that can generate errors are (roughly)
- Database is not available
- SQL failed to execute
Currently conditions like the input JSON not being valid or empty is flagged via additional environment variables and response is delegated to the SQL function.
For the simplest applications the current layout might be appropriate but once the application starts using something like JSON-RPC the simple version fails to be appropriate.
Simple alternative to current simple is just to have a directory with designated files containing error templates (sprintf) where the single parameter value is the error message.
For JSON-RPC this probably doesn't work as we probably need to use a value from the input JSON in the error JSON. Is it possible to use a JSON template file to define the error structure if we also have a defined namespace defined to allow access to all relevant values (input.json.id input.env.remote_addr jpig.error.message) ?