app/cyclid/controllers/organizations/job.rb in cyclid-0.3.3 vs app/cyclid/controllers/organizations/job.rb in cyclid-0.4.0
- old
+ new
@@ -102,10 +102,11 @@
# Sinatra callback
# @private
def self.registered(app)
include Errors::HTTPErrors
+ include Exceptions
include Constants::JobStatus
# Return a list of jobs
app.get do
authorized_for!(params[:name], Operations::READ)
@@ -178,15 +179,15 @@
authorized_for!(params[:name], Operations::WRITE)
payload = parse_request_body
Cyclid.logger.debug payload
- halt_with_json_response(400, INVALID_JOB, 'invalid job definition') \
- unless payload.key? 'sequence' and \
- payload.key? 'environment'
-
begin
job_id = job_from_definition(payload)
+ rescue NotFoundError => ex
+ halt_with_json_response(404, INVALID_ORG, ex.to_s)
+ rescue InvalidObjectError => ex
+ halt_with_json_response(400, INVALID_JOB, ex.to_s)
rescue StandardError => ex
halt_with_json_response(500, INVALID_JOB, "job failed: #{ex}")
end
return { job_id: job_id }.to_json