class SubCipher::SubCipherError

A customized exception for SubCipher

Constants

ERRORS

Errors used in SubCipher

Attributes

code[R]
info[R]
msg[R]
value[R]

Public Class Methods

new(error, info = {}) click to toggle source

The SubCipherError constructor. @param error [Fixnum, String]

You can give a error number defined in the keys of {SubCipher::SubCipherError::ERRORS} or a string message for internal usage.

@param info [Hash]

Anything you want to put in the info attribute of SubCipherError.
# File lib/sub_cipher/sub_cipher_error.rb, line 29
def initialize(error, info = {})
  @code = error
  @info = info
  if ERRORS.keys.include?(error)
    @value = ERRORS[error][:value]
    @msg = ERRORS[error][:msg]
  elsif error.class.name == 'String'
    @code = :internal
    @value = 90000
    @msg = error
  else
    @code = :internal
    @value = 99999
    @msg = "Internal Error"
  end
end