Skip to content

Commit

Permalink
catched exception for build log retrieve
Browse files Browse the repository at this point in the history
  • Loading branch information
charliemaiors committed Apr 21, 2016
1 parent f25fded commit 19d5e1a
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import org.springframework.context.annotation.Scope;
import org.springframework.http.*;
import org.springframework.stereotype.Service;
import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.client.HttpServerErrorException;
import org.springframework.web.client.RestTemplate;

import javax.annotation.PostConstruct;
Expand Down Expand Up @@ -93,7 +95,15 @@ public String retrieveLogs(String baseURL, String appName, String namespace, Htt
Build target = this.retrieveBuild(baseURL,appName,namespace,authHeader);
String URL = baseURL + namespace + suffix + target.getMetadata().getName() + logSuffix;
HttpEntity<String> logEntity = new HttpEntity<>(authHeader);
ResponseEntity<String> res = template.exchange(URL,HttpMethod.GET,logEntity,String.class);
ResponseEntity<String> res = null;

try {
res = template.exchange(URL, HttpMethod.GET, logEntity, String.class);
} catch (HttpServerErrorException e){
return "Build logs not anymore available";
} catch (HttpClientErrorException e){
return "Problems on communication with PaaS";
}

if(res.getStatusCode() != HttpStatus.OK){
logger.debug("Error retrieving logs " + res.getStatusCode() + " response " + res.toString());
Expand Down

0 comments on commit 19d5e1a

Please sign in to comment.