Exception: RandomToken::RandomTokenError
- Inherits:
-
StandardError
- Object
- StandardError
- RandomToken::RandomTokenError
- Defined in:
- lib/random_token/random_token_error.rb
Overview
A customized exception for RandomToken
Constant Summary
- 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." }, :format_not_support_byte => { :value => 10, :msg => "The byte-length is not supported in the format mode." }, :not_support_byte => { :value => 11, :msg => "The byte-length feature is not supported in this case, but the byte option is true." }, }
Instance Attribute Summary (collapse)
-
- (Object) code
readonly
Returns the value of attribute code.
-
- (Object) info
readonly
Returns the value of attribute info.
-
- (Object) msg
readonly
Returns the value of attribute msg.
-
- (Object) value
readonly
Returns the value of attribute value.
Instance Method Summary (collapse)
-
- (RandomTokenError) initialize(error, info = {})
constructor
The RandomTokenError constructor.
-
- (Object) message
Override the message method to show more information in RandomTokenError.
Constructor Details
- (RandomTokenError) initialize(error, info = {})
The RandomTokenError constructor.
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# 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 |
Instance Attribute Details
- (Object) code (readonly)
Returns the value of attribute code
54 55 56 |
# File 'lib/random_token/random_token_error.rb', line 54 def code @code end |
- (Object) info (readonly)
Returns the value of attribute info
54 55 56 |
# File 'lib/random_token/random_token_error.rb', line 54 def info @info end |
- (Object) msg (readonly)
Returns the value of attribute msg
54 55 56 |
# File 'lib/random_token/random_token_error.rb', line 54 def msg @msg end |
- (Object) value (readonly)
Returns the value of attribute value
54 55 56 |
# File 'lib/random_token/random_token_error.rb', line 54 def value @value end |
Instance Method Details
- (Object) message
Override the message method to show more information in RandomTokenError
79 80 81 |
# File 'lib/random_token/random_token_error.rb', line 79 def "RandomTokenError(#{@code.to_s}): value = #{@value}, msg = #{@msg}, info = #{@info.inspect}" end |