rotisserie/eris

Add more control over error format

sum2000 opened this issue · 3 comments

Is your feature request related to a problem? Please describe.
Currently, it is not possible to show/hide a certain part of the error frame. For ex., only show the method name or line number instead of a complete frame.

Describe the solution you'd like
One solution could be to provide some utility methods for the format object, like format.Show(file, method, line) and users can pass format.Show(true, true, false).

Describe alternatives you've considered
Another solution could be to have an object like options and users could pass options.line = false or something like that.

Copying the description of a duplicate issue here:

Do we always want to return all three pieces (name, file, line number)? Or do we want to let users decide what to print? This could include an option to shorten file paths (to just the file name?).

This could also include an option for printing logical stack traces instead of full stack traces (see https://middlemost.com/failure-is-your-domain/).

Another option is something like this:
type FrameFormatter func(frame StackFrame) string
which could be assigned to a field in the FormatOptions type. This would allow users to pass custom funcs that could do something totally different from the default way. If the field is nil when passed, we can use the default instead.

I don't think there's a major need for this. Closing it for now.