Exception: OrchestratorClient::ApiError
- Inherits:
-
RuntimeError
- Object
- RuntimeError
- OrchestratorClient::ApiError
- Defined in:
- lib/orchestrator_client/error.rb
Direct Known Subclasses
DependencyCycle, EmptyEnvironment, EmptyTarget, PuppetdbError, QueryError, UnauthorizedError, UnknownEnvironment, UnknownError, UnknownJob, ValidationError
Defined Under Namespace
Classes: DependencyCycle, EmptyEnvironment, EmptyTarget, PuppetdbError, QueryError, UnauthorizedError, UnknownEnvironment, UnknownError, UnknownJob, ValidationError
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(data, code) ⇒ ApiError
constructor
A new instance of ApiError.
Constructor Details
#initialize(data, code) ⇒ ApiError
Returns a new instance of ApiError.
7 8 9 10 11 12 |
# File 'lib/orchestrator_client/error.rb', line 7 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
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 44 45 46 |
# File 'lib/orchestrator_client/error.rb', line 14 def self.make_error_from_response(res) begin data = JSON.parse(res.body) rescue return OrchestratorClient::BadResponse.new("Response body was not valid JSON: #{res.body}") 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 OrchestratorClient::ApiError.new(data, code) end end |