Exception: RandomToken::RandomTokenError
- Inherits:
-
StandardError
- Object
- StandardError
- RandomToken::RandomTokenError
- Defined in:
- lib/code_error/random_token_error.rb
Overview
A customized exception for RandomToken
Constant Summary collapse
- ERRORS =
Errors used in RandomToken
{ :unknown_seed => { :value => 1, :msg => "Unknown given seed" }, :not_support_case => { :value => 2, :msg => "Case feature is not supported in this case, but the case option is given." }, :not_support_friendly => { :value => 3, :msg => "Friendly feature is not supported in this case, but the friendly option is true." }, :false_friendly_with_given_mask => { :value => 4, :msg => "The mask is given but the friendly option is false." }, :invalid_strf_pattern => { :value => 5, :msg => "The given pattern is invalid." }, :invalid_gen_arg => { :value => 6, :msg => "The given arg is invalid." }, :mask_remove_all_seeds => { :value => 7, :msg => "The friendly mask removes all seeds." }, :duplicated_option => { :value => 8, :msg => "The same options are given." }, :invalid_option_value => { :value => 9, :msg => "The given option value is invalid." }, }
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#info ⇒ Object
readonly
Returns the value of attribute info.
-
#msg ⇒ Object
readonly
Returns the value of attribute msg.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(error, info = {}) ⇒ RandomTokenError
constructor
The RandomTokenError constructor.
-
#message ⇒ Object
Override the message method to show more information in RandomTokenError.
Constructor Details
#initialize(error, info = {}) ⇒ RandomTokenError
The RandomTokenError constructor.
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/code_error/random_token_error.rb', line 53 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 |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
46 47 48 |
# File 'lib/code_error/random_token_error.rb', line 46 def code @code end |
#info ⇒ Object (readonly)
Returns the value of attribute info.
46 47 48 |
# File 'lib/code_error/random_token_error.rb', line 46 def info @info end |
#msg ⇒ Object (readonly)
Returns the value of attribute msg.
46 47 48 |
# File 'lib/code_error/random_token_error.rb', line 46 def msg @msg end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
46 47 48 |
# File 'lib/code_error/random_token_error.rb', line 46 def value @value end |
Instance Method Details
#message ⇒ Object
Override the message method to show more information in RandomTokenError
71 72 73 |
# File 'lib/code_error/random_token_error.rb', line 71 def "RandomTokenError(#{@code.to_s}): value = #{@value}, msg = #{@msg}, info = #{@info.inspect}" end |