Exception: Crabstone::Error

Inherits:
StandardError
  • Object
show all
Defined in:
lib/crabstone/error.rb,
lib/crabstone/error.rb

Constant Summary collapse

ERRNO =
{
  0 => ErrOK,
  1 => ErrMem,
  2 => ErrArch,
  3 => ErrHandle,
  4 => ErrCsh,
  5 => ErrMode,
  6 => ErrOption,
  7 => ErrDetail,
  8 => ErrMemSetup,
  9 => ErrVersion,
  10 => ErrDiet,
  11 => ErrSkipData,
  12 => ErrX86ATT,
  13 => ErrX86Intel,
  14 => ErrX86MASM
}.freeze

Class Method Summary collapse

Class Method Details

.raise!(klass) ⇒ Object



68
69
70
71
72
# File 'lib/crabstone/error.rb', line 68

def self.raise!(klass)
  raise "Invalid error class: #{klass}" unless klass.superclass == self

  raise_errno!(ERRNO.invert[klass])
end

.raise_errno!(errno) ⇒ Object

Raises:

  • (err_klass)


60
61
62
63
64
65
66
# File 'lib/crabstone/error.rb', line 60

def self.raise_errno!(errno)
  err_klass = ERRNO[errno]
  raise 'Internal Error: Tried to raise unknown errno' unless err_klass

  err_str = Binding.cs_strerror(errno)
  raise err_klass, err_str
end