Skip to content

Commit

Permalink
add not found image #11
Browse files Browse the repository at this point in the history
  • Loading branch information
pawlakm committed Mar 10, 2016
1 parent 1e5533c commit 50b67c9
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* qualinsight-plugins-sonarqube-badges
* Copyright (c) 2015, QualInsight
* http://www.qualinsight.com/
*
* This program is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program. If not, you can retrieve a copy
* from <http://www.gnu.org/licenses/>.
*/
package com.qualinsight.plugins.sonarqube.badges.internal;

import java.io.IOException;

public class ProjectNotFoundException extends IOException {

/**
*
*/
private static final long serialVersionUID = 1L;

}
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,13 @@ public enum QualityGateStatus {
*/
ERROR("failing",
new Color(224, 93, 68, 255),
44);
44),
/**
* The project / view does not pass the quality gate due to gate errors.
*/
NOT_FOUND("not found",
new Color(224, 93, 68, 255),
65);

private final String displayText;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ public String handleResponse(final HttpResponse response) throws IOException {
if ((status >= 200) && (status < 300)) {
final HttpEntity entity = response.getEntity();
return entity != null ? EntityUtils.toString(entity) : null;
} else if (status == 404) {
throw new ProjectNotFoundException();
} else {
throw new ClientProtocolException("Unexpected response status: " + status);
}
Expand All @@ -99,6 +101,8 @@ public QualityGateStatus retrieveFor(final String key) {
QualityGateStatus status;
try {
status = statusFromReponseBody(responseBodyForKey(key));
} catch (final ProjectNotFoundException e) {
status = QualityGateStatus.NOT_FOUND;
} catch (URISyntaxException | IOException | JSONException e) {
status = QualityGateStatus.SERVER_ERROR;
// We do not want to spam server logs with malformed requests, therefore we only log in debug mode
Expand Down

0 comments on commit 50b67c9

Please sign in to comment.