class RandomToken::RandomTokenError
A customized exception for RandomToken
Constants
- ERRORS
Errors used in
RandomToken
Attributes
code[R]
info[R]
msg[R]
value[R]
Public Class Methods
new(error, info = {})
click to toggle source
The RandomTokenError
constructor. @param error [Fixnum, String]
You can give a error number defined in the keys of {RandomToken::RandomTokenError::ERRORS} or a string message for internal usage.
@param info [Hash]
Anything you want to put in the info attribute of RandomTokenError.
# File lib/random_token/random_token_error.rb, line 61 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
Public Instance Methods
message()
click to toggle source
Override the message method to show more information in RandomTokenError
# File lib/random_token/random_token_error.rb, line 79 def message "RandomTokenError(#{@code.to_s}): value = #{@value}, msg = #{@msg}, info = #{@info.inspect}" end