Skip to content

Commit

Permalink
Merge pull request #8735 from TexasDigitalLibrary/DS-8668
Browse files Browse the repository at this point in the history
DS-8668: adds exception handler for when maximum upload size is exceeded
  • Loading branch information
tdonohue committed Apr 14, 2023
2 parents 1e14974 + d3e70c4 commit cc6c840
Showing 1 changed file with 8 additions and 0 deletions.
Expand Up @@ -42,6 +42,7 @@
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.context.request.WebRequest;
import org.springframework.web.multipart.MaxUploadSizeExceededException;
import org.springframework.web.multipart.MultipartException;
import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;

Expand Down Expand Up @@ -97,6 +98,13 @@ protected void handleWrongRequestException(HttpServletRequest request, HttpServl
sendErrorResponse(request, response, ex, "Request is invalid or incorrect", HttpServletResponse.SC_BAD_REQUEST);
}

@ExceptionHandler(MaxUploadSizeExceededException.class)
protected void handleMaxUploadSizeExceededException(HttpServletRequest request, HttpServletResponse response,
Exception ex) throws IOException {
sendErrorResponse(request, response, ex, "Request entity is too large",
HttpServletResponse.SC_REQUEST_ENTITY_TOO_LARGE);
}

@ExceptionHandler(SQLException.class)
protected void handleSQLException(HttpServletRequest request, HttpServletResponse response, Exception ex)
throws IOException {
Expand Down

0 comments on commit cc6c840

Please sign in to comment.