/
HttpResponseException.java
116 lines (101 loc) · 3.8 KB
/
HttpResponseException.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
package com.azure.core.exception;
import com.azure.core.http.HttpResponse;
/**
* The exception thrown when an unsuccessful response is received with http status code (e.g. 3XX, 4XX, 5XX) from the
* service request.
*/
public class HttpResponseException extends AzureException {
/**
* The HTTP response value.
*/
private final Object value;
/**
* Information about the associated HTTP response.
*/
private final HttpResponse response;
/**
* Initializes a new instance of the HttpResponseException class.
*
* @param response The {@link HttpResponse} received that is associated to the exception.
*/
public HttpResponseException(final HttpResponse response) {
super();
this.value = null;
this.response = response;
}
/**
* Initializes a new instance of the HttpResponseException class.
*
* @param message The exception message.
* @param response The {@link HttpResponse} received that is associated to the exception.
*/
public HttpResponseException(final String message, final HttpResponse response) {
super(message);
this.value = null;
this.response = response;
}
/**
* Initializes a new instance of the HttpResponseException class.
*
* @param response The {@link HttpResponse} received that is associated to the exception.
* @param cause The {@link Throwable} which caused the creation of this exception.
*/
public HttpResponseException(final HttpResponse response, final Throwable cause) {
super(cause);
this.value = null;
this.response = response;
}
/**
* Initializes a new instance of the HttpResponseException class.
*
* @param message The exception message.
* @param response The {@link HttpResponse} received that is associated to the exception.
* @param value The deserialized response value.
*/
public HttpResponseException(final String message, final HttpResponse response, final Object value) {
super(message);
this.value = value;
this.response = response;
}
/**
* Initializes a new instance of the HttpResponseException class.
*
* @param message The exception message.
* @param response The {@link HttpResponse} received that is associated to the exception.
* @param cause The {@link Throwable} which caused the creation of this exception.
*/
public HttpResponseException(final String message, final HttpResponse response, final Throwable cause) {
super(message, cause);
this.value = null;
this.response = response;
}
/**
* Initializes a new instance of the HttpResponseException class.
*
* @param message The exception message.
* @param response The {@link HttpResponse} received that is associated to the exception.
* @param cause The {@link Throwable} which caused the creation of this exception.
* @param enableSuppression Whether suppression is enabled or disabled.
* @param writableStackTrace Whether the exception stack trace will be filled in.
*/
public HttpResponseException(final String message, final HttpResponse response, final Throwable cause,
final boolean enableSuppression, final boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
this.value = null;
this.response = response;
}
/**
* @return The {@link HttpResponse} received that is associated to the exception.
*/
public HttpResponse getResponse() {
return response;
}
/**
* @return The deserialized HTTP response value.
*/
public Object getValue() {
return value;
}
}