travis-api/lib/travis/api/app/helpers.rb
Hiro Asari cc03c5458a DRY up log patching logic
Move the shared logic into a Helpers method so that there is no
code duplication
2014-06-11 18:07:12 -04:00

23 lines
602 B
Ruby

require 'travis/api/app'
class Travis::Api::App
# Namespace for helpers.
module Helpers
Backports.require_relative_dir 'helpers'
def patch_log_for_job(id, params)
result = self.service(:remove_log, params)
respond_with result
rescue Travis::AuthorizationDenied => ade
status 401
{ error: { message: ade.message } }
rescue Travis::JobUnfinished, Travis::LogAlreadyRemoved => e
status 409
{ error: { message: e.message } }
rescue => e
status 500
{ error: { message: "Unexpected error occurred: #{e.message}" } }
end
end
end