Class: SpecForge::Error::LoadStepError

Inherits:
Error
  • Object
show all
Defined in:
lib/spec_forge/error.rb

Overview

Raised when an error occurs while loading a step during blueprint processing

Wraps the original error with step context information to help identify which step caused the problem.

Instance Method Summary collapse

Constructor Details

#initialize(error, step, depth = 0) ⇒ LoadStepError

Returns a new instance of LoadStepError.



273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
# File 'lib/spec_forge/error.rb', line 273

def initialize(error, step, depth = 0)
  step_name = step[:name].presence || "(unnamed)"

  line_info = if (source = step[:source])
    "#{source[:file_name]}:#{source[:line_number]}"
  end

  message = "Step: #{step_name.in_quotes} [#{line_info}]"

  cause_message = if error.is_a?(LoadStepError)
    "\n#{error.message}"
  else
    "\n\nCaused by: \n  #{error.message.gsub("\n", "\n  ")}"
  end

  super(message + cause_message)
end