Sha256: 67da03d1ae75225f195a7fcfecd7ccfc868a197066882afa97d017a8484d2884

Contents?: true

Size: 1.05 KB

Versions: 4

Compression:

Stored size: 1.05 KB

Contents

module Net; module SFTP

  # The base exception class for the SFTP system.
  class Exception < RuntimeError; end

  # A exception class for reporting a non-success result of an operation.
  class StatusException < Net::SFTP::Exception

    # The response object that caused the exception.
    attr_reader :response

    # The error code (numeric)
    attr_reader :code

    # The description of the error
    attr_reader :description

    # Any incident-specific text given when the exception was raised
    attr_reader :text

    # Create a new status exception that reports the given code and
    # description.
    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

    # Override the default message format, to include the code and
    # description.
    def message
      m = super
      m << " #{text}" if text
      m << " (#{code}, #{description.inspect})"
    end

  end
end; end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
net-sftp-2.0.3 lib/net/sftp/errors.rb
net-sftp-2.0.1 lib/net/sftp/errors.rb
net-sftp-2.0.0 lib/net/sftp/errors.rb
net-sftp-2.0.2 lib/net/sftp/errors.rb