Leveled approach to errors - Proof of Concept (WIP) This project exists just to test possible design for adding stacktaces to go errors
Thanks to @mitar and golang community in general for ideas
mostly from this conversation
and from the leveled approach to logging used in log/slog
The interface of standard errors is unchanged
Much of the functionality is in the internal folder
There are some hacks to emulate the standard library for Errorf function
Hopefully this can be a good idea to add to the design of stacktraces in standard golang errors
There are 4 levels of errors as of now
suggestions to remove/add/modify levels are welcome
use stackLevelVar to make it dynamic (like log/slog LevelVar)
- LevelNoStack - behaves as if errors have no stacktrace infos (default)
- LevelProgramCounter - adds program counter to error
- LevelStackOnFirst level adds stacktrace to first error and PC to following errors
- LevelFullStack - adds stacktrace to all errors (personally I do not like this one)
Errors are generated by configurable structs that contain the StackLevel field
- errorer
- errorFormatter
StackDetails are generated by configurable struct which contains DetailFunc
- detailer
Should the errors tree be explored when exracting the error details?
(i.e.: when joined errors are wrapped) Not for now.
Should we have another configuation variable for this functionality??
CLimbTheTreeVar (??)