@@ -37,12 +37,15 @@ public class ResourceException extends RuntimeException {
3737
3838 private static final long serialVersionUID = 1L ;
3939
40- /** The resource associated to this exception. Could be null. */
41- private final Resource resource ;
42-
4340 /** The status associated to this exception. */
4441 private final Status status ;
4542
43+ /** The request associated to this exception. Could be null. */
44+ private final Request request ;
45+
46+ /** The response associated to this exception. Could be null. */
47+ private final Response response ;
48+
4649 /**
4750 * Constructor.
4851 *
@@ -186,22 +189,34 @@ public ResourceException(int code, Throwable throwable, String reasonPhrase, Str
186189 * The status to associate.
187190 */
188191 public ResourceException (Status status ) {
189- this (status , (Throwable ) (( status == null ) ? null : status .getThrowable () ));
192+ this (status , (status == null ) ? null : status .getThrowable ());
190193 }
191194
192195 /**
193196 * Constructor.
194197 *
195198 * @param status
196199 * The status to associate.
200+ * @deprecated use constructor with status, request and response instead.
197201 */
202+ @ Deprecated
198203 public ResourceException (Status status , Resource resource ) {
199- this (status , (Throwable ) (( status == null ) ? null : status .getThrowable ()), resource );
204+ this (status , (status == null ) ? null : status .getThrowable (), resource . getRequest ( ), resource . getResponse () );
200205 }
201206
202207 /**
203208 * Constructor.
204- *
209+ *
210+ * @param status
211+ * The status to associate.
212+ */
213+ public ResourceException (Status status , Request request , Response response ) {
214+ this (status , (status == null ) ? null : status .getThrowable (), request , response );
215+ }
216+
217+ /**
218+ * Constructor.
219+ *
205220 * @param status
206221 * The status to copy.
207222 * @param description
@@ -227,34 +242,36 @@ public ResourceException(Status status, String description, Throwable cause) {
227242
228243 /**
229244 * Constructor.
230- *
245+ *
231246 * @param status
232247 * The status to associate.
233248 * @param cause
234249 * The wrapped cause error or exception.
235250 */
236251 public ResourceException (Status status , Throwable cause ) {
237- this (status , cause , null );
252+ this (status , cause , null , null );
238253 }
239254
240255 /**
241256 * Constructor.
242- *
257+ *
243258 * @param status
244259 * The status to associate.
245260 * @param cause
246261 * The wrapped cause error or exception.
247262 */
248- public ResourceException (Status status , Throwable cause , Resource resource ) {
263+ public ResourceException (Status status , Throwable cause , Request request , Response response ) {
249264 super ((status == null ) ? null : status .toString (), cause );
250265 this .status = status ;
251- this .resource = resource ;
266+ this .request = request ;
267+ this .response = response ;
252268 }
253269
254270 /**
255- * Constructor that set the status to {@link org.restlet.data.Status#SERVER_ERROR_INTERNAL} including the
271+ * Constructor that set the status to
272+ * {@link org.restlet.data.Status#SERVER_ERROR_INTERNAL} including the
256273 * related error or exception.
257- *
274+ *
258275 * @param cause
259276 * The wrapped cause error or exception.
260277 */
@@ -264,34 +281,25 @@ public ResourceException(Throwable cause) {
264281
265282 /**
266283 * Returns the request associated to this exception.
267- *
284+ *
268285 * @return The request associated to this exception.
269286 */
270287 public Request getRequest () {
271- return (this .resource != null ) ? this .resource .getRequest () : null ;
272- }
273-
274- /**
275- * Returns the resource associated to this exception.
276- *
277- * @return The resource associated to this exception.
278- */
279- public Resource getResource () {
280- return this .resource ;
288+ return this .request ;
281289 }
282290
283291 /**
284292 * Returns the response associated to this exception.
285- *
293+ *
286294 * @return The response associated to this exception.
287295 */
288296 public Response getResponse () {
289- return ( this .resource != null ) ? this . resource . getResponse () : null ;
297+ return this .response ;
290298 }
291299
292300 /**
293301 * Returns the status associated to this exception.
294- *
302+ *
295303 * @return The status associated to this exception.
296304 */
297305 public Status getStatus () {
0 commit comments