From 6e91e81140c44e34c26ddba6b818f97216ebd5e9 Mon Sep 17 00:00:00 2001 From: thadeu Date: Tue, 7 May 2024 04:06:51 +0000 Subject: [PATCH] added Zx::AbortError --- lib/zx.rb | 9 +++++++++ 1 file changed, 9 insertions(+) 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)) }