diff --git a/lib/zx.rb b/lib/zx.rb index 33b8148..30ab9a6 100644 --- a/lib/zx.rb +++ b/lib/zx.rb @@ -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)) }