Skip to content
This repository has been archived by the owner on Jan 25, 2022. It is now read-only.

Commit

Permalink
Changelog:
Browse files Browse the repository at this point in the history
* logging request details nicely, including payload
* error handling fix, exceptions converted to java RuntimeException, related to JENKINS-24232
* on error displaying stack trace as well
  • Loading branch information
elvanja committed Oct 24, 2014
1 parent f5085ae commit 81e2725
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions models/api.rb
Expand Up @@ -11,6 +11,7 @@

java_import Java.java.util.logging.Logger
java_import Java.java.util.logging.Level
java_import Java.org.jruby.exceptions.RaiseException

module GitlabWebHook
class Api < Sinatra::Base
Expand Down Expand Up @@ -50,16 +51,21 @@ def process_projects(action)
rescue => e
# avoid method signature warnings
severe = LOGGER.java_method(:log, [Level, java.lang.String, java.lang.Throwable])
severe.call(Level::SEVERE, e.message, e)
severe.call(Level::SEVERE, e.message, RaiseException.new(e))
status 500
e.message
[e.message, '', 'Stack trace:', e.backtrace].flatten.join('<br>')
end

def parse_request
details = ParseRequest.new.from(params, request)
LOGGER.info("gitlab web hook triggered for repo url #{details.repository_url} and #{details.branch} branch")
LOGGER.info("with payload: #{details.payload}")
details
ParseRequest.new.from(params, request).tap do |details|
LOGGER.info([
'gitlab web hook triggered for',
" - repo url: #{details.repository_url}",
" - branch: #{details.branch}",
' - with payload:',
details.payload.pretty_inspect
].join("\n"))
end
end
end
end

0 comments on commit 81e2725

Please sign in to comment.