async
async copied to clipboard
Show annotation when logging exception
Uncaught exceptions in tasks is shown in a format starting with a line like this:
0.0s error: Async::Task [oid=0x3c] [pid=9016] [2020-12-16 21:01:17 +0100]
It would be useful if the task annotation was shown, to quickly identify the failed task.
It's a nice idea.
require '../lib/async'
Async do |task|
task.annotate "I'm going to fail!"
raise "Boom"
end
Results in:
What do you think?
That would work!
I was wondering if it could be in the line: Async::Task [oid=0x3c] [pid=9016] [2020-12-16 21:01:17 +0100]
But maybe that's output by Ruby and cannot be changed?
It's probably more that it's just too long to put on the same line.
But maybe that's output by Ruby and cannot be changed?
It's part of the console gem, it can be changed, but I guess we should consider it could be a long annotation.
Right, it can be long. A line of it's own is probably better.
Just for continuity, I'm still considering how best to integrate this feature: https://bugs.ruby-lang.org/issues/19056
In the latest commit of Async and Console gems, this is now possible. It's implemented by a shared gem, finer-annotation. Anyone can use it.
If you have any thoughts about better formatting, please feel free to open an issue/PR on the console gem.
https://github.com/socketry/console
(I already noticed the color issue of the annotation, so I'll fix it).