module Eco::API::UseCases::GraphQL::Helpers::Base # Basic stuff you would need in any use case module ErrorHandling include Eco::Language::AuxiliarLogger attr_reader :exception private def interrupted?(err = exception) interrupt_errors.any? {|klass| err.is_a?(klass)} end def error_raised? exception && !interrupted? end def rescued yield rescue StandardError => err self.exception ||= err log(:error) { err.patch_full_message } end def with_error_handling @exception = nil yield rescue SystemExit => sext @exception = sext exit sext.status rescue *interrupt_errors => int @exception = int raise rescue SystemStackError puts $! # rubocop:disable Style/SpecialGlobalVars puts caller[0..100] raise rescue StandardError, SignalException => err @exception = err raise end def interrupt_errors return @interrupt_errors if @interrupt_errors errs = [Interrupt] errs << IRB::Abort if Object.const_defined?(:IRB) && IRB.const_defined?(:Abort) @interrupt_errors = errs end end end