Skip to content

Commit

Permalink
Restore error logging. (#331)
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix authored Jul 15, 2024
1 parent 70fbc6c commit 99dea7e
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions lib/async/task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,15 @@ def run(*arguments)

schedule do
@block.call(self, *arguments)
rescue => error
# I'm not completely happy with this overhead, but the alternative is to not log anything which makes debugging extremely difficult. Maybe we can introduce a debug wrapper which adds extra logging.
if @finished.nil?
Console::Event::Failure.for(error).emit("Task may have ended with unhandled exception.", severity: :warn)
# else
# Console::Event::Failure.for(error).emit(self, severity: :debug)
end

raise
end
else
raise RuntimeError, "Task already running!"
Expand Down Expand Up @@ -358,12 +367,6 @@ def completed!(result)
def failed!(exception = false)
@result = exception
@status = :failed

if $DEBUG
Fiber.blocking do
$stderr.puts "Task #{self} failed:", exception.full_message
end
end
end

def stopped!
Expand Down Expand Up @@ -398,7 +401,6 @@ def schedule(&block)

begin
completed!(yield)
# Console.debug(self) {"Task was completed with #{@children.size} children!"}
rescue Stop
stopped!
rescue StandardError => error
Expand Down

0 comments on commit 99dea7e

Please sign in to comment.