Skip to content
This repository was archived by the owner on Oct 20, 2022. It is now read-only.

Commit a05203a

Browse files
Add a convenience method for sending an error response using ResponseStatus.
1 parent 15f4ee5 commit a05203a

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/main/java/com/google/visualization/datasource/DataSourceHelper.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,21 @@ public static void setServletErrorResponse(DataSourceException dataSourceExcepti
224224
setServletResponse(responseMessage, dataSourceRequest, res);
225225
}
226226

227+
/**
228+
* Sets the HTTP servlet response in case of an error.
229+
*
230+
* @param responseStatus The response status.
231+
* @param dataSourceRequest The data source request.
232+
* @param res The http servlet response.
233+
*
234+
* @throws IOException In case an error happened trying to write the response to the servlet.
235+
*/
236+
public static void setServletErrorResponse(ResponseStatus responseStatus,
237+
DataSourceRequest dataSourceRequest, HttpServletResponse res) throws IOException {
238+
String responseMessage = generateErrorResponse(responseStatus, dataSourceRequest);
239+
setServletResponse(responseMessage, dataSourceRequest, res);
240+
}
241+
227242
/**
228243
* Sets the HTTP servlet response in case of an error.
229244
*

0 commit comments

Comments
 (0)