Class: Yobi::ExitError

Inherits:
FancyHash show all
Defined in:
lib/yobi/errors.rb,
sig/yobi.rbs

Overview

The exit_error message from a fatal Restic run, if one was printed. https://restic.readthedocs.io/en/stable/075_scripting.html#exit-errors

Constant Summary collapse

LINE_PATTERN =

Returns:

  • (Regexp)
/"message_type"\s*:\s*"exit_error"/

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from FancyHash

#initialize, #inspect, #pretty_print

Constructor Details

This class inherits a constructor from Yobi::FancyHash

Class Method Details

.from_output(output) ⇒ Yobi::ExitError?

Returns nil if no exit_error line is present.

Parameters:

Returns:



17
18
19
20
# File 'lib/yobi/errors.rb', line 17

def self.from_output(output)
  line = output.each_line.find { |candidate| LINE_PATTERN.match?(candidate) }
  new(JSON.parse(line)) if line
end

Instance Method Details

#codeString?

Returns:

  • (String, nil)


23
24
25
# File 'lib/yobi/errors.rb', line 23

def code
  self["code"]
end

#messageString?

Returns:

  • (String, nil)


28
29
30
# File 'lib/yobi/errors.rb', line 28

def message
  self["message"]
end