Exception: Backup::Errors::Error

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(msg = nil, orig_err = nil) ⇒ Error

Returns a new instance of Error.



66
67
68
69
# File 'lib/backup/errors.rb', line 66

def initialize(msg = nil, orig_err = nil)
  super(msg)
  set_backtrace(orig_err.backtrace) if @orig_err = orig_err
end

Class Method Details

.wrap(orig_err, msg = nil) ⇒ Object



62
63
64
# File 'lib/backup/errors.rb', line 62

def self.wrap(orig_err, msg = nil)
  new(msg, orig_err)
end

Instance Method Details

#to_sObject



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/backup/errors.rb', line 71

def to_s
  return @to_s if @to_s
  orig_to_s = super()

  if orig_to_s == self.class.to_s
    msg = orig_err_msg ?
        "#{orig_err_class}: #{orig_err_msg}" : orig_err_class
  else
    msg = format_msg(orig_to_s)
    msg << "\n  Reason: #{orig_err_class}" + (orig_err_msg ?
        "\n  #{orig_err_msg}" : ' (no message given)') if @orig_err
  end

  @to_s = msg ? msg_prefix + msg : class_name
end