Adds backend handler for NullEmail and it's respected custom HttpCode.

This commit is contained in:
gkolokythas 2019-07-12 17:01:00 +03:00
parent 25da5e97e5
commit b691084d73
2 changed files with 22 additions and 1 deletions

View File

@ -0,0 +1,19 @@
package eu.eudat.controllers.controllerhandler;
import eu.eudat.exceptions.security.NullEmailException;
import eu.eudat.models.data.helpers.responses.ResponseItem;
import eu.eudat.types.ApiMessageCode;
import org.springframework.core.annotation.Order;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
@ControllerAdvice
@Order(2)
public class ControllerUserNullEmailHandler {
@ExceptionHandler(NullEmailException.class)
public ResponseEntity nullEmailException(Exception ex) throws Exception {
return ResponseEntity.status(ApiMessageCode.NULL_EMAIL.getValue()).body("");
}
}

View File

@ -2,7 +2,7 @@ package eu.eudat.types;
public enum ApiMessageCode { public enum ApiMessageCode {
NO_MESSAGE(0), SUCCESS_MESSAGE(200), WARN_MESSAGE(300), ERROR_MESSAGE(400), NO_MESSAGE(0), SUCCESS_MESSAGE(200), WARN_MESSAGE(300), ERROR_MESSAGE(400),
DEFAULT_ERROR_MESSAGE(444), VALIDATION_MESSAGE(445), UNSUCCESS_DELETE(674); DEFAULT_ERROR_MESSAGE(444), VALIDATION_MESSAGE(445),NULL_EMAIL(480), UNSUCCESS_DELETE(674);
private Integer value; private Integer value;
@ -26,6 +26,8 @@ public enum ApiMessageCode {
return ERROR_MESSAGE; return ERROR_MESSAGE;
case 444: case 444:
return DEFAULT_ERROR_MESSAGE; return DEFAULT_ERROR_MESSAGE;
case 480:
return NULL_EMAIL;
case 674: case 674:
return UNSUCCESS_DELETE; return UNSUCCESS_DELETE;
default: default: