Exception: Tryouts::TryoutSyntaxError

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

Overview

Enhanced error with context

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, line_number:, context:, source_file: nil) ⇒ TryoutSyntaxError

Returns a new instance of TryoutSyntaxError.



183
184
185
186
187
188
189
190
# File 'lib/tryouts/test_case.rb', line 183

def initialize(message, line_number:, context:, source_file: nil)
  @line_number = line_number
  @context     = context
  @source_file = source_file

  location = source_file ? "#{source_file}:#{line_number}" : "line #{line_number}"
  super("#{message} at #{location}: #{context}")
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



181
182
183
# File 'lib/tryouts/test_case.rb', line 181

def context
  @context
end

#line_numberObject (readonly)

Returns the value of attribute line_number.



181
182
183
# File 'lib/tryouts/test_case.rb', line 181

def line_number
  @line_number
end

#source_fileObject (readonly)

Returns the value of attribute source_file.



181
182
183
# File 'lib/tryouts/test_case.rb', line 181

def source_file
  @source_file
end