4 ms·
I always try to follow a similar set of guidelines, but errors in literally any programming language just sucks at it. The proper error object should have these
by wruza 5y ago
I always try to follow a similar set of guidelines, but errors in literally any programming language just sucks at it. The proper error object should have these properties:
system info:
which module/function
what it tried to do
what it expected
what happened
important context values
[how to restart]
[how to cleanup]
underlying error object
…
…
user info:
human-oriented message
ways to resolve
formatting:
format for logging (a stack of messages)
format as json schema
format for debugging (a detailed stack of messages interspersed with a call stack)
format for innocent user
You may recognize first few lines as standard questions to answer before posting an issue. Instead we usually have a message field and maybe some call stack. Error paths can be half of a decent long-running program, but all we have is a stupid string and no standard way to extend that.