Exception: PgVerify::Interpret::InterpretError

Inherits:
Core::Error
  • Object
show all
Defined in:
lib/pg-verify/interpret/interpret.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Core::Error

#to_formatted

Constructor Details

#initialize(script_file, line_number, cause) ⇒ InterpretError

Returns a new instance of InterpretError.



13
14
15
# File 'lib/pg-verify/interpret/interpret.rb', line 13

def initialize(script_file, line_number, cause)
    @script_file, @line_number, @cause = script_file, line_number, cause
end

Instance Attribute Details

#causeObject

Returns the value of attribute cause.



11
12
13
# File 'lib/pg-verify/interpret/interpret.rb', line 11

def cause
  @cause
end

#line_numberObject

Returns the value of attribute line_number.



10
11
12
# File 'lib/pg-verify/interpret/interpret.rb', line 10

def line_number
  @line_number
end

#script_fileObject

Returns the value of attribute script_file.



9
10
11
# File 'lib/pg-verify/interpret/interpret.rb', line 9

def script_file
  @script_file
end

Instance Method Details

#format_causeObject



28
29
30
31
# File 'lib/pg-verify/interpret/interpret.rb', line 28

def format_cause()
    return "#{cause}" unless cause.is_a?(Core::Error)
    return cause.to_formatted()
end

#formattedObject



17
18
19
20
21
22
23
24
25
26
# File 'lib/pg-verify/interpret/interpret.rb', line 17

def formatted()
    title = "Error while interpreting script at #{@script_file}:#{@line_number}"
    cause_str = format_cause()

    sloc = Model::SourceLocation.new(@script_file, @line_number)
    code_block = sloc.render_code_block

    body = "#{code_block}\n\n#{cause_str}"
    return title, body
end