Skip to content

Commit b27cd0a

Browse files
committed
Lift SolidClientExceptions members to parent
1 parent 93cfccf commit b27cd0a

File tree

1 file changed

+53
-10
lines changed

1 file changed

+53
-10
lines changed

api/src/main/java/com/inrupt/client/ClientHttpException.java

Lines changed: 53 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,35 +20,78 @@
2020
*/
2121
package com.inrupt.client;
2222

23+
import java.net.URI;
24+
2325
/**
2426
* A runtime exception representing an HTTP error response carrying a structured representation of the problem. The
2527
* problem description is embedded in a {@link ProblemDetails} instance.
2628
*/
2729
public class ClientHttpException extends InruptClientException {
2830
private final ProblemDetails problemDetails;
31+
private final URI uri;
32+
private final int statusCode;
33+
private final String body;
34+
private final transient Headers headers;
2935

3036
/**
3137
* Create a ClientHttpException.
32-
* @param problemDetails the {@link ProblemDetails} instance
3338
* @param message the exception message
39+
* @param uri the error response URI
40+
* @param statusCode the error response status code
41+
* @param headers the error response headers
3442
*/
35-
public ClientHttpException(final ProblemDetails problemDetails, final String message) {
43+
public ClientHttpException(final String message, final URI uri, final int statusCode,
44+
final Headers headers, final String body) {
3645
super(message);
37-
this.problemDetails = problemDetails;
46+
this.uri = uri;
47+
this.statusCode = statusCode;
48+
this.headers = headers;
49+
this.body = body;
50+
this.problemDetails = ProblemDetails.fromErrorResponse(statusCode, headers, body.getBytes());
3851
}
3952

4053
/**
41-
* Create a ClientHttpException.
42-
* @param problemDetails the {@link ProblemDetails} instance
43-
* @param message the exception message
44-
* @param cause a wrapped exception cause
54+
* Retrieve the URI associated with this exception.
55+
*
56+
* @return the uri
57+
*/
58+
public URI getUri() {
59+
return uri;
60+
}
61+
62+
/**
63+
* Retrieve the status code associated with this exception.
64+
*
65+
* @return the status code
66+
*/
67+
public int getStatusCode() {
68+
return statusCode;
69+
}
70+
71+
/**
72+
* Retrieve the headers associated with this exception.
73+
*
74+
* @return the headers
4575
*/
46-
public ClientHttpException(final ProblemDetails problemDetails, final String message, final Exception cause) {
47-
super(message, cause);
48-
this.problemDetails = problemDetails;
76+
public Headers getHeaders() {
77+
return headers;
4978
}
5079

80+
/**
81+
* Retrieve the body associated with this exception.
82+
*
83+
* @return the body
84+
*/
85+
public String getBody() {
86+
return body;
87+
}
88+
89+
/**
90+
* Retrieve the {@link ProblemDetails} instance describing the HTTP error response.
91+
* @return the problem details object
92+
*/
5193
public ProblemDetails getProblemDetails() {
5294
return this.problemDetails;
5395
}
96+
5497
}

0 commit comments

Comments
 (0)