Class: HumanError
- Inherits:
-
Object
show all
- Defined in:
- lib/human_error.rb,
lib/human_error/error.rb,
lib/human_error/version.rb,
lib/human_error/persistable.rb,
lib/human_error/configuration.rb,
lib/human_error/utilities/string.rb,
lib/human_error/errors/crud_error.rb,
lib/human_error/rescuable_resource.rb,
lib/human_error/error_code_directory.rb,
lib/human_error/errors/request_error.rb,
lib/human_error/knowledgebase_id_directory.rb,
lib/human_error/errors/authentication_error.rb,
lib/human_error/errors/crud_errors/association_error.rb,
lib/human_error/errors/crud_errors/resource_not_found_error.rb,
lib/human_error/errors/crud_errors/resource_persistence_error.rb,
lib/human_error/errors/authentication_errors/invalid_token_error.rb,
lib/human_error/errors/authentication_errors/duplicate_authentication_error.rb,
lib/human_error/errors/authentication_errors/invalid_username_or_password_error.rb
Defined Under Namespace
Modules: Error, Errors, Persistable, RescuableResource, Utilities
Classes: Configuration, ErrorCodeDirectory, KnowledgebaseIdDirectory
Constant Summary
collapse
- VERSION =
'1.13.3'
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize {|configuration| ... } ⇒ HumanError
Returns a new instance of HumanError.
8
9
10
11
12
|
# File 'lib/human_error.rb', line 8
def initialize
self.configuration = Configuration.new
yield configuration if block_given?
end
|
Instance Attribute Details
#configuration ⇒ Object
Returns the value of attribute configuration.
6
7
8
|
# File 'lib/human_error.rb', line 6
def configuration
@configuration
end
|
Class Method Details
.configuration ⇒ Object
20
21
22
|
# File 'lib/human_error/configuration.rb', line 20
def self.configuration
@configuration ||= Configuration.new
end
|
16
17
18
|
# File 'lib/human_error/configuration.rb', line 16
def self.configure
yield configuration
end
|
Instance Method Details
#fetch(error_type, **args) ⇒ Object
14
15
16
17
|
# File 'lib/human_error.rb', line 14
def fetch(error_type, **args)
Object.const_get("HumanError::Errors::#{error_type}").
new(configuration.to_h.merge(**args))
end
|
#raise(error_type, **args) ⇒ Object
19
20
21
22
23
|
# File 'lib/human_error.rb', line 19
def raise(error_type, **args)
error = fetch(error_type, **args)
Kernel.raise error
end
|