Skip to content

Commit

Permalink
added Zx::AbortError
Browse files Browse the repository at this point in the history
  • Loading branch information
thadeu committed May 7, 2024
1 parent 51e8a10 commit 6e91e81
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/zx.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@
require 'zx/result'

module Zx
class AbortError < ::RuntimeError
attr_reader :type

def initialize(message: nil, type: :error)
@type = type
super(message)
end
end

module Methods
Success = ->(value = nil, options = {}) { Zx.Success(value, { type: :ok }.merge(options)) }
Failure = ->(value = nil, options = {}) { Zx.Failure(value, { type: :error }.merge(options)) }
Expand Down

0 comments on commit 6e91e81

Please sign in to comment.