Exception: Laser::Error

Inherits:
StandardError show all
Defined in:
lib/laser/analysis/errors.rb

Overview

Base class for all Laser errors. Has a few fields that are important for later referencing during error reporting.

Constant Summary

ADVISORY =
1
STYLE =
2
MINOR_WARNING =
3
WARNING =
4
MAJOR_WARNING =
5
SIMPLE_ERROR =
6
ERROR =
7
TRICKY_ERROR =
8
MAJOR_ERROR =
9
FUCKUP =
10

Constants inherited from Exception

Exception::BT_FAILURE_MESSAGE

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Exception

#backtrace, #set_backtrace, #to_s

Constructor Details

#initialize(message, ast_node, severity = 5) ⇒ Error



23
24
25
26
# File 'lib/laser/analysis/errors.rb', line 23

def initialize(message, ast_node, severity = 5)
  super(message)
  @ast_node, @severity = ast_node, severity
end

Instance Attribute Details

#ast_nodeObject

Returns the value of attribute ast_node



22
23
24
# File 'lib/laser/analysis/errors.rb', line 22

def ast_node
  @ast_node
end

#severityObject

Returns the value of attribute severity



22
23
24
# File 'lib/laser/analysis/errors.rb', line 22

def severity
  @severity
end

Class Method Details

.severity(new_severity) ⇒ Object



16
17
18
19
20
# File 'lib/laser/analysis/errors.rb', line 16

def self.severity(new_severity)
  define_method :initialize do |msg, node|
    super(msg, node, new_severity)
  end
end

Instance Method Details

#==(other) ⇒ Object



28
29
30
31
# File 'lib/laser/analysis/errors.rb', line 28

def ==(other)
  other.class == self.class && other.message == self.message &&
      other.ast_node == self.ast_node && self.severity == other.severity
end

#inspectObject



37
38
39
# File 'lib/laser/analysis/errors.rb', line 37

def inspect
  "#<#{self.class}: #{message} (#{ast_node.file_name}:#{ast_node.source_begin[0]})>"
end

#line_numberObject



33
34
35
# File 'lib/laser/analysis/errors.rb', line 33

def line_number
  ast_node.line_number
end