Exception: Ftpd::FtpServerError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/ftpd/exceptions.rb

Overview

Any error that send a reply to the client raises a FtpServerError. The message is the text to send (e.g. “Syntax error”) and the code is the FTP response code to send (e.g. “502”). This is typically not raised directly, but using the Error mixin.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, code) ⇒ FtpServerError

Returns a new instance of FtpServerError.

Raises:

  • (ArgumentError)


16
17
18
19
20
21
# File 'lib/ftpd/exceptions.rb', line 16

def initialize(message, code)
  @code = code
  raise ArgumentError, "Invalid response code" unless valid_response_code?

  super(message)
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



14
15
16
# File 'lib/ftpd/exceptions.rb', line 14

def code
  @code
end

Instance Method Details

#message_with_codeObject



23
24
25
# File 'lib/ftpd/exceptions.rb', line 23

def message_with_code
  "#{code} #{message}"
end