Skip to content

Commit

Permalink
Merge pull request #14 from telebugs/promise-rescue
Browse files Browse the repository at this point in the history
Expose #rescue
  • Loading branch information
kyrylo committed Jun 13, 2024
2 parents 4a5f9d5 + 5c2ce73 commit 2adc6ff
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/telebugs/promise.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,9 @@ def rejected?
def then(...)
@future.then(...)
end

def rescue(...)
@future.rescue(...)
end
end
end
6 changes: 6 additions & 0 deletions test/test_promise.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,10 @@ def test_then

assert_equal 4, p.value
end

def test_rescue
p = Telebugs::Promise.new { raise "error" }.rescue { |e| e.message }

assert_equal "error", p.value
end
end

0 comments on commit 2adc6ff

Please sign in to comment.