Exception: Orchestrator_api::Error
- Inherits:
-
Exception
- Object
- Exception
- Orchestrator_api::Error
- Defined in:
- lib/orchestrator_api/error.rb
Direct Known Subclasses
DependencyCycle, EmptyEnvironment, EmptyTarget, PuppetdbError, QueryError, UnauthorizedError, UnknownEnvironment, UnknownError, UnknownJob, ValidationError
Defined Under Namespace
Classes: DependencyCycle, EmptyEnvironment, EmptyTarget, EndpointError, PuppetdbError, QueryError, UnauthorizedError, UnknownEnvironment, UnknownError, UnknownJob, ValidationError
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(data, code) ⇒ Error
constructor
A new instance of Error.
Constructor Details
#initialize(data, code) ⇒ Error
Returns a new instance of Error.
4 5 6 7 8 9 |
# File 'lib/orchestrator_api/error.rb', line 4 def initialize(data,code) @code = code @kind = data['kind'] @details = data['details'] super(data['msg']) end |
Class Method Details
.make_error_from_response(res) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/orchestrator_api/error.rb', line 11 def self.make_error_from_response(res) begin data = JSON.parse(res.body) rescue return EndpointError.new("An unspecified error has occurred with the Orchestrator API") end code = res.code case data['kind'] when 'puppetlabs.validators/validation-error' ValidationError.new(data, code) when 'puppetlabs.orchestrator/unknown-job' UnknownJob.new(data, code) when 'puppetlabs.orchestrator/unknown-environment' UnknownEnvironment.new(data, code) when 'puppetlabs.orchestrator/empty-environment' EmptyEnvironment.new(data, code) when 'puppetlabs.orchestrator/empty-target' EmptyTarget.new(data, code) when 'puppetlabs.orchestrator/dependency-cycle' DependencyCycle.new(data, code) when 'puppetlabs.orchestrator/puppetdb-error' PuppetdbError.new(data, code) when 'puppetlabs.orchestrator/query-error' QueryError.new(data, code) when 'puppetlabs.orchestrator/unknown-error' UnknownError.new(data, code) when 'puppetlabs.orchestrator/not-permitted' .new(data, code) else EndpointError.new("An unspecified error has occurred with the Orchestrator API") end end |