socketry / async

An awesome asynchronous event-driven reactor for Ruby.
MIT License
2.12k stars 86 forks source link

[Enhanchment] Make alternate exception reporting (the colorful one) opt in. #261

Closed jsaak closed 1 year ago

jsaak commented 1 year ago

While yours is usable, i prefer the standard ruby one. Using both is confusing for me.

ioquatix commented 1 year ago

Because exceptions do not propagate up to the very top of Ruby, the formatting has to be done by some user-level code.

This is done by the console gem here: https://github.com/socketry/console/blob/main/lib/console/event/failure.rb#L46-L72

We could make this a little more flexible but it's not a personal priority of mine.

Alternatively, if you just want to remove the color you can run like this:

image

i.e. specify CONSOLE_OUTPUT=Text to force non-XTerm output.

I'm pretty sure you are after the former, not the latter. In that case, you could write your own output formatter e.g. CONSOLE_OUTPUT=MyCustomFormatter. It is just a class that implements #call(subject, *arguments, **options) where arguments may be [exception] in your case.

jsaak commented 1 year ago

If i recreate the original MRI error messages in a function, would you be interested to make that default? :) Fortunately this is not very important. Closing for now. Maybe if I am not alone with my request they can +1, or something.

ioquatix commented 1 year ago

The original MRI formatting is missing important context, e.g. which fiber failed, etc. I don't think this is worth the effort, but if the integration is minimal then I don't say no. You'd probably need to make a PR to the console gem.