Added handler for MaxUploadSizeExceededException; hardcoded for MonitoringError
This commit is contained in:
parent
a67478e350
commit
86bbfe16eb
1 changed files with 15 additions and 0 deletions
|
|
@ -6,7 +6,9 @@ import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||||
|
import org.springframework.web.multipart.MaxUploadSizeExceededException;
|
||||||
import ru.nbch.credit_tracker.entities.response.errors.*;
|
import ru.nbch.credit_tracker.entities.response.errors.*;
|
||||||
|
import ru.nbch.credit_tracker.enums.SignalError;
|
||||||
import ru.nbch.credit_tracker.exceptions.SignalClientException;
|
import ru.nbch.credit_tracker.exceptions.SignalClientException;
|
||||||
import ru.nbch.credit_tracker.exceptions.SignalException;
|
import ru.nbch.credit_tracker.exceptions.SignalException;
|
||||||
import ru.nbch.credit_tracker.utils.error.SimpleMessageResolver;
|
import ru.nbch.credit_tracker.utils.error.SimpleMessageResolver;
|
||||||
|
|
@ -18,6 +20,19 @@ public class GlobalExceptionHandler {
|
||||||
|
|
||||||
private final SimpleMessageResolver messageResolver = new SimpleMessageResolver();
|
private final SimpleMessageResolver messageResolver = new SimpleMessageResolver();
|
||||||
|
|
||||||
|
@ExceptionHandler(value = MaxUploadSizeExceededException.class, produces = MediaType.APPLICATION_XML_VALUE)
|
||||||
|
public ResponseEntity<MonitoringError> handleMaxUploadSizeExceeded(MaxUploadSizeExceededException ex) {
|
||||||
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
headers.setContentType(new MediaType("application", "xml", Charset.forName("windows-1251")));
|
||||||
|
|
||||||
|
MonitoringError error = new MonitoringError();
|
||||||
|
error.setStatus("error");
|
||||||
|
error.setErrorCode(SignalError.ERROR_009.getCode());
|
||||||
|
error.setErrorText(SignalError.ERROR_009.getKey());
|
||||||
|
|
||||||
|
return new ResponseEntity<>(error, headers, HttpStatus.BAD_REQUEST);
|
||||||
|
}
|
||||||
|
|
||||||
@ExceptionHandler(value = SignalException.class, produces = MediaType.APPLICATION_XML_VALUE)
|
@ExceptionHandler(value = SignalException.class, produces = MediaType.APPLICATION_XML_VALUE)
|
||||||
public ResponseEntity<CommonError> handleClientException(SignalException ex) {
|
public ResponseEntity<CommonError> handleClientException(SignalException ex) {
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue