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)


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

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.



12
13
14
# File 'lib/ftpd/exceptions.rb', line 12

def code
  @code
end

Instance Method Details

#message_with_codeObject



21
22
23
# File 'lib/ftpd/exceptions.rb', line 21

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