module Tryouts::ClassMethods

def batch_stopping_error?(exception)

Determine if an error should stop batch execution
def batch_stopping_error?(exception)
  classification = classify_error(exception)
  [:non_recoverable_exit, :system_resource, :syntax].include?(classification)
end

def classify_error(exception)

Error classification for resilient error handling
def classify_error(exception)
  case exception
  when SystemExit, SignalException
    :non_recoverable_exit
  when Timeout::Error
    :transient
  when Errno::ENOENT, Errno::EACCES, Errno::EPERM
    :file_system
  when LoadError, NameError, NoMethodError
    :code_structure
  when SecurityError, NoMemoryError, SystemStackError
    :system_resource
  when SyntaxError, TryoutSyntaxError
    :syntax
  when StandardError
    :recoverable
  else
    :unknown
  end
end

def debug(msg, indent: 0)

def debug(msg, indent: 0)
  return unless debug?
  prefix = ('  ' * indent) + Console.color(:cyan, 'DEBUG')
  warn "#{prefix} #{msg}"
end

def debug?

def debug?
  @debug == true
end

def test_stopping_error?(exception)

Determine if an error should stop individual test execution
def test_stopping_error?(exception)
  classification = classify_error(exception)
  [:non_recoverable_exit, :system_resource].include?(classification)
end

def trace(msg, indent: 0)

def trace(msg, indent: 0)
  return unless debug?
  prefix = ('  ' * indent) + Console.color(:dim, 'TRACE')
  warn "#{prefix} #{msg}"
end

def update_load_path(lib_glob)

def update_load_path(lib_glob)
  Dir.glob(lib_glob).each { |dir| $LOAD_PATH.unshift(dir) }
end