Skip to content

Commit

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

schedule do
@block.call(self, *arguments)
rescue => error
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 +366,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 +400,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 2b02ce2

Please sign in to comment.