Sha256: 7bb4ed9989379235f24728d06932dd9798defbddfb04ad451696816b776a2ede
Contents?: true
Size: 1.96 KB
Versions: 1
Compression:
Stored size: 1.96 KB
Contents
module Eco module API class UseCases class OozeSamples module Helpers module Rescuable module InstanceMethods private # Helper to prevent script from stopping def with_rescue(reference) raise ArgumentError, "Expecting block, but not given" unless block_given? yield rescue StandardError => e log(:error) { [reference, e.message].join(' => \n') } lines = [] lines << "\nThere was an error. Choose one option:\n" lines << " (C) - Continue/resume. Just ignore this one." lines << " (A) - Abort. Just break this run." session.prompt_user('Type one option (C/a):', explanation: lines.join("\n"), default: 'C') do |res| res = res.upcase case when res.start_with?("A") raise else res.start_with?("C") log(:warn) { msg = "Script resumed after error..." msg << "\n • #{reference}" } nil end end end end class << self def included(base) super validate_base_type!(base) base.include(InstanceMethods) end def validate_base_type!(base) return super if defined?(super) msg = "#{self} can only be included in Eco::API::Common::Loaders::Base" msg << "\nCan't be included in #{base}" raise LoadError, msg unless base <= Eco::API::Common::Loaders::Base true end end end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
eco-helpers-2.6.2 | lib/eco/api/usecases/ooze_samples/helpers/rescuable.rb |