Exception: MotherBrain::MBError
- Inherits:
-
StandardError
- Object
- StandardError
- MotherBrain::MBError
show all
- Defined in:
- lib/mb/errors.rb
Direct Known Subclasses
APIError, BootstrapError, BootstrapTemplateNotFound, ChefConnectionError, ChefError, ChefRunFailure, ChefRunnerError, ChefTestRunFailure, CommandNotFound, ComponentNotFound, ComponentNotVersioned, ConfigExists, ConfigNotFound, ConfigOptionMissing, EnvironmentNotFound, FileNotFound, GearError, InternalError, InvalidBootstrapManifest, InvalidConfig, InvalidDynamicService, InvalidEnvironmentJson, InvalidLockType, InvalidManifest, InvalidProvisionManifest, JobNotFound, ManifestNotFound, NoBootstrapRoutine, OmnibusUpgradeError, PluginDownloadError, PluginLoadError, PluginNotFound, PluginSyntaxError, PrerequisiteNotInstalled, ProvisionError, RequiredFileNotFound, ResourceLocked
Constant Summary
collapse
- DEFAULT_EXIT_CODE =
1
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(message = nil) ⇒ MBError
Returns a new instance of MBError.
52
53
54
55
|
# File 'lib/mb/errors.rb', line 52
def initialize(message = nil)
super(message)
@message = message
end
|
Class Method Details
.error_code(code = -1)) ⇒ Integer
43
44
45
46
47
48
|
# File 'lib/mb/errors.rb', line 43
def error_code(code = -1)
return @error_code if @error_code
@error_code = code
Errors.register(self)
@error_code
end
|
.exit_code(code = DEFAULT_EXIT_CODE) ⇒ Integer
36
37
38
|
# File 'lib/mb/errors.rb', line 36
def exit_code(code = DEFAULT_EXIT_CODE)
@exit_code ||= code
end
|
Instance Method Details
#error_code ⇒ Integer
63
64
65
|
# File 'lib/mb/errors.rb', line 63
def error_code
self.class.error_code
end
|
#exit_code ⇒ Integer
58
59
60
|
# File 'lib/mb/errors.rb', line 58
def exit_code
self.class.exit_code
end
|
#message ⇒ String
68
69
70
|
# File 'lib/mb/errors.rb', line 68
def message
@message || self.class.to_s
end
|
#to_hash ⇒ Object
76
77
78
79
80
81
|
# File 'lib/mb/errors.rb', line 76
def to_hash
{
code: error_code,
message: message
}
end
|
#to_json(options = {}) ⇒ String
87
88
89
|
# File 'lib/mb/errors.rb', line 87
def to_json(options = {})
MultiJson.encode(self.to_hash, options)
end
|
#to_s ⇒ Object
72
73
74
|
# File 'lib/mb/errors.rb', line 72
def to_s
"[err_code]: #{error_code} [message]: #{message}"
end
|