Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions lib/jenkins_api_client/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -815,8 +815,7 @@ def handle_exception(response, to_send = "code", send_json = false)
return response
end
when 400
matched = response.body.match(/<p>(.*)<\/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/
Expand Down Expand Up @@ -851,5 +850,24 @@ def handle_exception(response, to_send = "code", send_json = false)
end
end

def getApiMsgFromError404(response)

matched = response.body.match(/<p>(.*)<\/p>/)
# unless matched.nil?
if (matched != nil)
result = matched[1]
else

matched = response.body.match(/<h2>(.*)<\/h2>/)
if (matched != nil)
result = matched[1]
else
result = nil
end
end

return result
end

end
end