Exception: Lutaml::ModelTransformations::Parsers::ParseError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/lutaml/model_transformations/parsers/base_parser.rb

Overview

Custom error class for parsing failures

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, original_error: nil, parser: nil, file_path: nil) ⇒ ParseError

Initialize parsing error

Parameters:

  • message (String)

    Error message

  • original_error (StandardError) (defaults to: nil)

    Original error

  • parser (BaseParser) (defaults to: nil)

    Parser that failed

  • file_path (String) (defaults to: nil)

    File that failed to parse



363
364
365
366
367
368
369
370
371
# File 'lib/lutaml/model_transformations/parsers/base_parser.rb', line 363

def initialize(
  message, original_error: nil, parser: nil,
  file_path: nil
)
  super(message)
  @original_error = original_error
  @parser = parser
  @file_path = file_path
end

Instance Attribute Details

#file_pathString (readonly)

Returns Path to file that failed to parse.

Returns:

  • (String)

    Path to file that failed to parse



355
356
357
# File 'lib/lutaml/model_transformations/parsers/base_parser.rb', line 355

def file_path
  @file_path
end

#original_errorStandardError (readonly)

Returns Original error that caused parsing failure.

Returns:

  • (StandardError)

    Original error that caused parsing failure



349
350
351
# File 'lib/lutaml/model_transformations/parsers/base_parser.rb', line 349

def original_error
  @original_error
end

#parserBaseParser (readonly)

Returns Parser instance that failed.

Returns:



352
353
354
# File 'lib/lutaml/model_transformations/parsers/base_parser.rb', line 352

def parser
  @parser
end

Instance Method Details

#detailsHash

Get detailed error information

Returns:

  • (Hash)

    Error details



376
377
378
379
380
381
382
383
384
385
# File 'lib/lutaml/model_transformations/parsers/base_parser.rb', line 376

def details # rubocop:disable Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
  {
    message: message,
    file_path: @file_path,
    parser: @parser&.class&.name,
    original_error: @original_error&.class&.name,
    original_message: @original_error&.message,
    backtrace: @original_error&.backtrace&.first(5),
  }
end