Class: Vagrant::Util::Errors
- Inherits:
-
Object
- Object
- Vagrant::Util::Errors
- Defined in:
- lib/vagrant/util/errors.rb
Overview
This class is responsible for outputting errors. It retrieves the errors, based on their key, from the error file, and then outputs it.
Constant Summary collapse
- @@errors =
nil
Class Method Summary collapse
-
.error_string(key, data = {}) ⇒ String
Renders the error with the given key and data parameters and returns the rendered result.
-
.errors ⇒ Hash
Returns the hash of errors from the error YML files.
-
.reset! ⇒ Object
Resets the internal errors hash to nil, forcing a reload on the next access of Errors.errors.
Class Method Details
.error_string(key, data = {}) ⇒ String
Renders the error with the given key and data parameters and returns the rendered result.
29 30 31 32 |
# File 'lib/vagrant/util/errors.rb', line 29 def error_string(key, data = {}) template = errors[key] || "Unknown error key: #{key}" TemplateRenderer.render_string(template, data) end |
.errors ⇒ Hash
Returns the hash of errors from the error YML files. This only loads once, then returns a cached value until reset! is called.
21 22 23 |
# File 'lib/vagrant/util/errors.rb', line 21 def errors @@errors ||= YAML.load_file(File.join(PROJECT_ROOT, "templates", "errors.yml")) end |
.reset! ⇒ Object
Resets the internal errors hash to nil, forcing a reload on the next access of errors.
13 14 15 |
# File 'lib/vagrant/util/errors.rb', line 13 def reset! @@errors = nil end |