diff --git a/lib/jenkins_api_client/client.rb b/lib/jenkins_api_client/client.rb index cee4c2cb..668fc19c 100644 --- a/lib/jenkins_api_client/client.rb +++ b/lib/jenkins_api_client/client.rb @@ -815,8 +815,7 @@ def handle_exception(response, to_send = "code", send_json = false) return response end when 400 - matched = response.body.match(/
(.*)<\/p>/) - api_message = matched[1] unless matched.nil? + api_message = getApiMsgFromError404 response @logger.debug "API message: #{api_message}" case api_message when /A job already exists with the name/ @@ -851,5 +850,24 @@ def handle_exception(response, to_send = "code", send_json = false) end end + def getApiMsgFromError404(response) + + matched = response.body.match(/
(.*)<\/p>/) + # unless matched.nil? + if (matched != nil) + result = matched[1] + else + + matched = response.body.match(/