Exception: Exception

Defined in:
lib/fOOrth/monkey_patch/exceptions.rb

Overview

Extensions to Exception to support fOOrth.

Direct Known Subclasses

Interrupt, RuntimeError, SystemCallError

Defined Under Namespace

Modules: Gem

Constant Summary collapse

FOORTH_EXCEPTION_CODE =

A hash of exception classes and their fOOrth codes.

{
    SignalException                             =>  "E30:",
Interrupt                                 =>  "E30,01:",
MiniReadlineEOI                           =>  "E30,02:",
    StandardError                               =>  "E:",
ArgumentError                             =>  "E01:",
  Gem::Requirement::BadRequirementError   =>  "E01,01:",
EncodingError                             =>  "E02:",
  Encoding::CompatibilityError            =>  "E02,01:",
  Encoding::ConverterNotFoundError        =>  "E02,02:",
  Encoding::InvalidByteSequenceError      =>  "E02,03:",
  Encoding::UndefinedConversionError      =>  "E02,04:",
FiberError                                =>  "E03:",
IOError                                   =>  "E04:",
  EOFError                                =>  "E04,01:",
IndexError                                =>  "E05:",
  KeyError                                =>  "E05,01:",
  StopIteration                           =>  "E05,02:",
LocalJumpError                            =>  "E06:",
Math::DomainError                         =>  "E07:",
NameError                                 =>  "E08:",
  NoMethodError                           =>  "E08,01:",
RangeError                                =>  "E09:",
  FloatDomainError                        =>  "E09,01:",
RegexpError                               =>  "E10:",
RuntimeError                              =>  "E11:",
  Gem::Exception                          =>  "E11,01:",
    Gem::CommandLineError                 =>  "E11,01,01:",
    Gem::DependencyError                  =>  "E11,01,02:",
    Gem::DependencyRemovalException       =>  "E11,01,03:",
    Gem::DependencyResolutionError        =>  "E11,01,04:",
    Gem::DocumentError                    =>  "E11,01,05:",
    Gem::EndOfYAMLException               =>  "E11,01,06:",
    Gem::FilePermissionError              =>  "E11,01,07:",
    Gem::FormatException                  =>  "E11,01,08:",
    Gem::GemNotFoundException             =>  "E11,01,09:",
      Gem::SpecificGemNotFoundException   =>  "E11,01,09,01:",
    Gem::GemNotInHomeException            =>  "E11,01,10:",
    Gem::ImpossibleDependenciesError      =>  "E11,01,11:",
    Gem::InstallError                     =>  "E11,01,12:",
    Gem::InvalidSpecificationException    =>  "E11,01,13:",
    Gem::OperationNotSupportedError       =>  "E11,01,14:",
    Gem::RemoteError                      =>  "E11,01,15:",
    Gem::RemoteInstallationCancelled      =>  "E11,01,16:",
    Gem::RemoteInstallationSkipped        =>  "E11,01,17:",
    Gem::RemoteSourceException            =>  "E11,01,18:",
   #Gem::RubyVersionMismatch              =>  "E11,01,19:",
    Gem::UnsatisfiableDependencyError     =>  "E11,01,20:",
    Gem::VerificationError                =>  "E11,01,21:",
     #SystemCallError                           =>  "E12,<error_name>:",
ThreadError                               =>  "E13:",
TypeError                                 =>  "E14:",
ZeroDivisionError                         =>  "E15:"}

Instance Method Summary collapse

Instance Method Details

#foorth_codeObject

Retrieve the fOOrth exception code of this exception.



66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/fOOrth/monkey_patch/exceptions.rb', line 66

def foorth_code
  if /^[A-Z]\d\d(,\d\d)*:/ =~ self.message
    result = $MATCH
  else
    klass = self.class

    while (klass)
      break if (result = FOORTH_EXCEPTION_CODE[klass])
      klass = klass.superclass
    end
  end

  result ||= "E??:"
end

#foorth_match(target) ⇒ Object

Is this exception covered by target?



82
83
84
# File 'lib/fOOrth/monkey_patch/exceptions.rb', line 82

def foorth_match(target)
  self.foorth_code[0, target.length] == target
end

#foorth_messageObject

Get the error message for this exception.



87
88
89
# File 'lib/fOOrth/monkey_patch/exceptions.rb', line 87

def foorth_message
  "#{self.foorth_code} #{self.message}"
end