Add spring exception handler for FileStreamingFailedException (#943)
Signed-off-by: Sebastian Firsching <sebastian.firsching@bosch-si.com>
This commit is contained in:
committed by
GitHub
parent
83161ea267
commit
46ce3b632a
@@ -21,6 +21,7 @@ import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||
import org.eclipse.hawkbit.exception.AbstractServerRtException;
|
||||
import org.eclipse.hawkbit.exception.SpServerError;
|
||||
import org.eclipse.hawkbit.rest.json.model.ExceptionInfo;
|
||||
import org.eclipse.hawkbit.rest.util.FileStreamingFailedException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -117,6 +118,28 @@ public class ResponseExceptionHandler {
|
||||
return new ResponseEntity<>(response, responseStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method for handling exception of type
|
||||
* {@link FileStreamingFailedException} which is thrown in case the
|
||||
* streaming of a file failed due to an internal server error. As the
|
||||
* streaming of the file has already begun, no JSON response but only the
|
||||
* ResponseStatus 500 is returned. Called by the Spring-Framework for
|
||||
* exception handling.
|
||||
*
|
||||
* @param request
|
||||
* the Http request
|
||||
* @param ex
|
||||
* the exception which occurred
|
||||
* @return the entity to be responded containing the response status 500
|
||||
*/
|
||||
@ExceptionHandler(FileStreamingFailedException.class)
|
||||
public ResponseEntity<Object> handleFileStreamingFailedException(final HttpServletRequest request,
|
||||
final Exception ex) {
|
||||
logRequest(request, ex);
|
||||
LOG.warn("File streaming failed: {}", ex.getMessage());
|
||||
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method for handling exception of type HttpMessageNotReadableException and
|
||||
* MethodArgumentNotValidException which are thrown in case the request body
|
||||
|
||||
Reference in New Issue
Block a user