Class: StunClient::RFC3489Message::ErrorCode

Inherits:
BinData::Record
  • Object
show all
Defined in:
lib/stun-client/rfc3489/message.rb

Overview

Represents the content of the attribute ‘ERROR-CODE’. This contains an error code like HTTP and an error message.

Constant Summary collapse

ERROR_MESSAGES =

Hash, which contains the error messages for the error class and the error number.

{
  4 => {
     0 => 'Bad request',
     1 => 'Unauthorized',
    20 => 'Unknown Attribute',
    30 => 'Stale Credentials',
    31 => 'Integrity Check Failure',
    32 => 'Missing Username',
    33 => 'Use TLS'
  }.freeze,
  5 => {
     0 => 'Server Error'
  }.freeze,
  6 => {
     0 => 'Global Failure:'
  }.freeze
}.freeze

Instance Method Summary collapse

Instance Method Details

#get_error_message(error_class, error_number) ⇒ String

Returns an error message for an error code.

Parameters:

  • error_class (Integer)

    Number containing the error class. Currently 4, 5 and 6 are supported.

  • error_number (Integer)

    Number, which contains the error number. This further classifies the error.

Returns:

  • (String)

    Returns the error message. If the error number is unknown, ‘’Unknown error number’‘ or `’Unknown error class’‘ accordingly.



76
77
78
79
80
81
82
83
84
85
# File 'lib/stun-client/rfc3489/message.rb', line 76

def get_error_message error_class, error_number
  if ERROR_MESSAGES.has_key? error_class
    if ERROR_MESSAGES[error_class].has_key? error_number
      return ERROR_MESSAGES[error_class][error_number]
    end

    return 'Unknown error number'
  end
  return 'Unknown error class'
end