Skip to content

Commit

Permalink
Fiber#run: use STDERR again, and give better error message
Browse files Browse the repository at this point in the history
Ary Borenszweig committed Jul 5, 2016

Verified

This commit was signed with the committer’s verified signature.
headius Charles Oliver Nutter
1 parent 104c9b9 commit 993bda1
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/fiber.cr
Original file line number Diff line number Diff line change
@@ -96,12 +96,13 @@ class Fiber
def run
@proc.call
rescue ex
# Don't use STDERR here because we are at a lower level than that
msg = String.build do |io|
io.puts "Unhandled exception:"
ex.inspect_with_backtrace io
if name = @name
STDERR.puts "Unhandled exception in spawn(name: #{name}):"
else
STDERR.puts "Unhandled exception in spawn:"
end
LibC.write(2, msg, msg.bytesize)
ex.inspect_with_backtrace STDERR
STDERR.flush
ensure
@@stack_pool << @stack

0 comments on commit 993bda1

Please sign in to comment.