async icon indicating copy to clipboard operation
async copied to clipboard

Show annotation when logging exception

Open emiltin opened this issue 4 years ago • 7 comments

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.

emiltin avatar Dec 16 '20 20:12 emiltin

It's a nice idea.

ioquatix avatar Dec 27 '20 07:12 ioquatix

require '../lib/async'

Async do |task|
	task.annotate "I'm going to fail!"
	raise "Boom"
end

Results in:

image

ioquatix avatar Dec 27 '20 07:12 ioquatix

What do you think?

ioquatix avatar Dec 27 '20 07:12 ioquatix

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?

emiltin avatar Dec 27 '20 08:12 emiltin

It's probably more that it's just too long to put on the same line.

ioquatix avatar Dec 27 '20 10:12 ioquatix

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.

ioquatix avatar Dec 27 '20 10:12 ioquatix

Right, it can be long. A line of it's own is probably better.

emiltin avatar Dec 27 '20 15:12 emiltin

Just for continuity, I'm still considering how best to integrate this feature: https://bugs.ruby-lang.org/issues/19056

ioquatix avatar Nov 01 '22 01:11 ioquatix

Screenshot 2023-06-06 at 11 50 31 AM

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.

ioquatix avatar Jun 06 '23 02:06 ioquatix

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).

ioquatix avatar Jun 06 '23 02:06 ioquatix