Class: Yobi::ExitError

Inherits:
SimpleDelegator
  • Object
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 =

Matches a JSON line with "message_type": "exit_error".

Returns:

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_output(output) ⇒ Yobi::ExitError?

Returns nil if no exit_error line is present.

Parameters:

Returns:



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

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)


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

def code
  self["code"]
end

#messageString?

Returns:

  • (String, nil)


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

def message
  self["message"]
end