Exception: DoiExtractor::CommandFailError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/doi_extractor/errors.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, inner_exception = nil, exit_code = 1) ⇒ CommandFailError

Returns a new instance of CommandFailError.



7
8
9
10
11
# File 'lib/doi_extractor/errors.rb', line 7

def initialize(message, inner_exception = nil, exit_code = 1)
  super(message)
  @inner_exception = inner_exception
  @exit_code = exit_code
end

Instance Attribute Details

#exit_codeObject (readonly)

Returns the value of attribute exit_code.



5
6
7
# File 'lib/doi_extractor/errors.rb', line 5

def exit_code
  @exit_code
end

#inner_exceptionObject (readonly)

Returns the value of attribute inner_exception.



5
6
7
# File 'lib/doi_extractor/errors.rb', line 5

def inner_exception
  @inner_exception
end

Instance Method Details

#error_reportObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/doi_extractor/errors.rb', line 13

def error_report
  report = []

  report << "Failed: #{self.message}"

  if inner_exception
    report << "caused by: #{inner_exception.class}: #{inner_exception.message}"
    inner_exception.backtrace.each do |l|
      report << "    #{l}"
    end
  end

  report << ' '

  report.join("\n")
end