mirror of
https://github.com/Kingsrook/qqq.git
synced 2025-07-17 20:50:44 +00:00
CE-1180 Add full QHttpResponse to BadResponse exception
This commit is contained in:
@ -594,7 +594,7 @@ public class BaseAPIActionUtil
|
||||
}
|
||||
|
||||
String warningMessage = "HTTP " + request.getMethod() + " for table [" + table.getName() + "] failed with status " + statusCode + ": " + resultString;
|
||||
throw (new QBadHttpResponseStatusException(warningMessage, statusCode));
|
||||
throw (new QBadHttpResponseStatusException(warningMessage, response));
|
||||
}
|
||||
|
||||
|
||||
|
@ -23,25 +23,30 @@ package com.kingsrook.qqq.backend.module.api.exceptions;
|
||||
|
||||
|
||||
import com.kingsrook.qqq.backend.core.exceptions.QException;
|
||||
import com.kingsrook.qqq.backend.module.api.actions.QHttpResponse;
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Exception thrown when an API HTTP request failed due to a bad status code.
|
||||
** This exception includes the status code as a field
|
||||
** This exception includes the status code as a field, as well as the full
|
||||
** response object.
|
||||
*******************************************************************************/
|
||||
public class QBadHttpResponseStatusException extends QException
|
||||
{
|
||||
private int statusCode;
|
||||
private int statusCode;
|
||||
private QHttpResponse response;
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
public QBadHttpResponseStatusException(String message, int statusCode)
|
||||
public QBadHttpResponseStatusException(String message, QHttpResponse response)
|
||||
{
|
||||
super(message);
|
||||
this.statusCode = statusCode;
|
||||
|
||||
this.statusCode = response.getStatusCode();
|
||||
this.response = response;
|
||||
}
|
||||
|
||||
|
||||
@ -75,4 +80,35 @@ public class QBadHttpResponseStatusException extends QException
|
||||
return (this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Getter for response
|
||||
*******************************************************************************/
|
||||
public QHttpResponse getResponse()
|
||||
{
|
||||
return (this.response);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Setter for response
|
||||
*******************************************************************************/
|
||||
public void setResponse(QHttpResponse response)
|
||||
{
|
||||
this.response = response;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Fluent setter for response
|
||||
*******************************************************************************/
|
||||
public QBadHttpResponseStatusException withResponse(QHttpResponse response)
|
||||
{
|
||||
this.response = response;
|
||||
return (this);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user