Exception: Net::NATPMP::RequestFailed

Inherits:
Exception
  • Object
show all
Includes:
Constants
Defined in:
lib/net/natpmp/errors.rb

Overview

Exception should be thrown when the request fails

Constant Summary

Constants included from Constants

Constants::BASE_DELAY, Constants::DEFAULT_INSIDE_PORT, Constants::DEFAULT_LIFETIME, Constants::DEFAULT_OUTSIDE_PORT, Constants::DEFAULT_PROTO, Constants::MAX_WAIT, Constants::OP_CODES, Constants::PROTO_CODES, Constants::RESULT_CODES, Constants::RESULT_CODES_DESC, Constants::VERSION

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ RequestFailed

Returns a new instance of RequestFailed.



25
26
27
28
29
30
31
32
33
# File 'lib/net/natpmp/errors.rb', line 25

def initialize(opts = {})
  msg = opts[:msg] || 'Failed to send the request'

  if (@result_code = opts[:result_code])
    msg = "#{msg}. Server replied: #{RESULT_CODES_DESC[@result_code]}(#{@result_code})"
  end

  super(msg)
end