travis-api/lib/travis/api/app/endpoint/logs.rb
Hiro Asari 8da49332d6 Clean up error handling for RemoveLog
With the error message change in travis-core, we can handle
2 exceptions in one rescue clause
2014-06-11 13:58:57 -04:00

32 lines
880 B
Ruby

require 'travis/api/app'
class Travis::Api::App
class Endpoint
# Logs are generated by builds.
class Logs < Endpoint
# Fetches a log by its *id*.
get '/:id' do |id|
respond_with service(:find_log, params)
end
# Clears up the content of the log by the *job id*
# Optionally takes parameter *reason*
patch '/:id' do |id|
begin
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
end
end