Exception: NuclearSecrets::NuclearSecretError
- Inherits:
-
StandardError
- Object
- StandardError
- NuclearSecrets::NuclearSecretError
show all
- Defined in:
- lib/nuclear_secrets/errors.rb
Instance Method Summary
collapse
Constructor Details
Returns a new instance of NuclearSecretError.
3
4
5
|
# File 'lib/nuclear_secrets/errors.rb', line 3
def initialize(secrets: [])
@secrets = secrets
end
|
Instance Method Details
#get_error_list ⇒ Object
30
31
32
33
34
35
36
|
# File 'lib/nuclear_secrets/errors.rb', line 30
def get_error_list
@secrets.reduce("") do |message, current|
message << current.first.to_s
message << required_type_message(current[1])
message << given_type_message(current.last)
end
end
|
#given_type_message(given_type) ⇒ Object
20
21
22
23
24
25
26
27
28
|
# File 'lib/nuclear_secrets/errors.rb', line 20
def given_type_message(given_type)
if given_type.nil?
"\n"
elsif given_type.class == String
" was given \"#{given_type}\"\n"
else
" was given #{given_type}\n"
end
end
|
#required_type_message(req_type) ⇒ Object
7
8
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/nuclear_secrets/errors.rb', line 7
def required_type_message(req_type)
if req_type.nil?
" of value nil"
elsif req_type.class == Class
" of type #{req_type}"
elsif req_type.class == Proc
source_pair = req_type.source_location
" of type Proc (defined in file: #{source_pair.first}, line: #{source_pair.last})"
else
" of value #{req_type}"
end
end
|