Skip to content

Commit c514f4a

Browse files
Adds a specific exception for HttpClient errors.
1 parent ee765b6 commit c514f4a

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

structurizr-client/src/main/java/com/structurizr/http/HttpClient.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public RemoteContent get(String url) {
6363
*/
6464
public RemoteContent get(String url, boolean cache) {
6565
if (!isAllowed(url)) {
66-
throw new RuntimeException("Access to " + url + " is not permitted");
66+
throw new HttpClientException("Access to " + url + " is not permitted");
6767
}
6868

6969
RemoteContent remoteContent = contentCache.get(url);
@@ -97,10 +97,10 @@ public RemoteContent get(String url, boolean cache) {
9797
contentCache.put(url, remoteContent);
9898
}
9999
} else {
100-
throw new RuntimeException("The content from " + url + " could not be loaded: HTTP status=" + httpStatus);
100+
throw new HttpClientException("The content from " + url + " could not be loaded: HTTP status=" + httpStatus);
101101
}
102102
} catch (Exception ioe) {
103-
throw new RuntimeException("The content from " + url + " could not be loaded: " + ioe.getMessage());
103+
throw new HttpClientException("The content from " + url + " could not be loaded: " + ioe.getMessage());
104104
}
105105
}
106106

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.structurizr.http;
2+
3+
public class HttpClientException extends RuntimeException {
4+
5+
public HttpClientException(String message) {
6+
super(message);
7+
}
8+
9+
}

0 commit comments

Comments
 (0)