Exception: Net::SFTP::StatusException

Inherits:
Exception
  • Object
show all
Defined in:
lib/net/sftp/errors.rb

Overview

A exception class for reporting a non-success result of an operation.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response, text = nil) ⇒ StatusException

Create a new status exception that reports the given code and description.



23
24
25
26
27
28
# File 'lib/net/sftp/errors.rb', line 23

def initialize(response, text=nil)
  @response, @text = response, text
  @code = response.code
  @description = response.message
  @description = Response::MAP[@code] if @description.nil? || @description.empty?
end

Instance Attribute Details

#codeObject (readonly)

The error code (numeric)



13
14
15
# File 'lib/net/sftp/errors.rb', line 13

def code
  @code
end

#descriptionObject (readonly)

The description of the error



16
17
18
# File 'lib/net/sftp/errors.rb', line 16

def description
  @description
end

#responseObject (readonly)

The response object that caused the exception.



10
11
12
# File 'lib/net/sftp/errors.rb', line 10

def response
  @response
end

#textObject (readonly)

Any incident-specific text given when the exception was raised



19
20
21
# File 'lib/net/sftp/errors.rb', line 19

def text
  @text
end

Instance Method Details

#messageObject

Override the default message format, to include the code and description.



32
33
34
35
36
# File 'lib/net/sftp/errors.rb', line 32

def message
  m = super.dup
  m << " #{text}" if text
  m << " (#{code}, #{description.inspect})"
end