Exception: Fuguta::SyntaxError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/fuguta.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root_cause, source = "") ⇒ SyntaxError

Returns a new instance of SyntaxError.

Raises:

  • (ArgumentError)


17
18
19
20
21
22
# File 'lib/fuguta.rb', line 17

def initialize(root_cause, source="")
  super("Syntax Error")
  raise ArgumentError, 'root_cause' unless root_cause.is_a?(::Exception)
  @root_cause = root_cause
  @source = source
end

Instance Attribute Details

#root_causeObject (readonly)

self.cause() is as of Ruby 2.1 so we handles root error .



15
16
17
# File 'lib/fuguta.rb', line 15

def root_cause
  @root_cause
end

#sourceObject (readonly)

self.cause() is as of Ruby 2.1 so we handles root error .



15
16
17
# File 'lib/fuguta.rb', line 15

def source
  @source
end

Instance Method Details

#messageObject



24
25
26
27
28
29
30
# File 'lib/fuguta.rb', line 24

def message
  if @root_cause.backtrace.first =~ /:(\d+):in `/ ||
      @root_cause.backtrace.first =~ /:(\d+)$/
    line = $1.to_i
  end
  "%s from %s:%d" % [super(), @source, line]
end