CE-1180 Add full QHttpResponse to BadResponse exception

This commit is contained in:
2024-05-14 08:31:40 -05:00
parent e7735619c1
commit 7a1b99bab3
2 changed files with 41 additions and 5 deletions

View File

@ -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));
}

View File

@ -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);
}
}