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.

Direct Known Subclasses

Analysis::Scope::ScopeLookupFailure, ConstantInForLoopError, DangerousOverrideError, DeadCodeWarning, DiscardedRHSError, DoubleIncludeError, DynamicSuperclassError, FailedAliasError, ImproperOverrideTypeError, IncompatibleArityError, MissingBlockError, NoMatchingTypeSignature, NoSuchMethodError, NotInMethodError, OverrideWithoutSuperError, ReopenedClassAsModuleError, ReopenedModuleAsClassError, SuperclassMismatchError, TopLevelSimulationRaised, UnassignedLHSError, UnnecessaryBlockError, UnusedVariableWarning

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

- (Error) initialize(message, ast_node, severity = 5)



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

- (Object) ast_node

Returns the value of attribute ast_node



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

def ast_node
  @ast_node
end

- (Object) severity

Returns the value of attribute severity



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

def severity
  @severity
end

Class Method Details

+ (Object) severity(new_severity)



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

- (Object) ==(other)



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

- (Object) inspect



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

- (Object) line_number



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

def line_number
  ast_node.line_number
end