Sha256: d991b8abe4bd8e2510df7c9649405a23d4098eb5021b30e472832b15b21395a4
Contents?: true
Size: 1.08 KB
Versions: 4
Compression:
Stored size: 1.08 KB
Contents
# frozen_string_literal: true module Lite module Command class Fault < StandardError attr_reader :caused_by, :thrown_by, :reason, :metadata def initialize(**params) @reason = params.fetch(:reason) @metadata = params.fetch(:metadata) @caused_by = params.fetch(:caused_by) @thrown_by = params.fetch(:thrown_by) super(reason) end def self.build(type, command, thrown_exception, dynamic: false) klass = dynamic ? command.class : Lite::Command fault = klass.const_get(type.to_s) fault = fault.new( reason: command.reason, metadata: command.metadata, caused_by: command.caused_by || command, thrown_by: command ) fault.set_backtrace(thrown_exception.backtrace) if thrown_exception.respond_to?(:backtrace) fault end def type @type ||= self.class.name.split("::").last.downcase end end class Noop < Fault; end class Invalid < Fault; end class Failure < Fault; end class Error < Fault; end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
lite-command-2.1.3 | lib/lite/command/fault.rb |
lite-command-2.1.2 | lib/lite/command/fault.rb |
lite-command-2.1.1 | lib/lite/command/fault.rb |
lite-command-2.1.0 | lib/lite/command/fault.rb |