Search in sources :

Example 91 with ExceptionHandler

use of org.springframework.web.bind.annotation.ExceptionHandler in project ArachneCentralAPI by OHDSI.

the class ExceptionHandlingController method exceptionHandler.

@ExceptionHandler(Exception.class)
public ResponseEntity<JsonResult> exceptionHandler(Exception ex) {
    LOGGER.error(ex.getMessage(), ex);
    JsonResult result = new JsonResult<>(SYSTEM_ERROR);
    result.setErrorMessage(ex.getMessage());
    return new ResponseEntity<>(result, HttpStatus.OK);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) JsonResult(com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult) ExceptionHandler(org.springframework.web.bind.annotation.ExceptionHandler)

Example 92 with ExceptionHandler

use of org.springframework.web.bind.annotation.ExceptionHandler in project ArachneCentralAPI by OHDSI.

the class ExceptionHandlingController method exceptionHandler.

@ResponseStatus(value = HttpStatus.INTERNAL_SERVER_ERROR)
@ExceptionHandler(ServiceNotAvailableException.class)
@ResponseBody
public JsonResult exceptionHandler(ServiceNotAvailableException ex) {
    LOGGER.warn(ex.getMessage());
    JsonResult result = new JsonResult(SYSTEM_ERROR);
    result.setErrorMessage(ex.getMessage());
    return result;
}
Also used : JsonResult(com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult) ExceptionHandler(org.springframework.web.bind.annotation.ExceptionHandler) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 93 with ExceptionHandler

use of org.springframework.web.bind.annotation.ExceptionHandler in project ArachneCentralAPI by OHDSI.

the class ExceptionHandlingController method exceptionHandler.

@ExceptionHandler(PermissionDeniedException.class)
public ResponseEntity<JsonResult> exceptionHandler(PermissionDeniedException ex) {
    LOGGER.error(ex.getMessage(), ex);
    JsonResult result = new JsonResult<>(PERMISSION_DENIED);
    result.setErrorMessage(ex.getMessage());
    return new ResponseEntity<>(result, HttpStatus.OK);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) JsonResult(com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult) ExceptionHandler(org.springframework.web.bind.annotation.ExceptionHandler)

Example 94 with ExceptionHandler

use of org.springframework.web.bind.annotation.ExceptionHandler in project ArachneCentralAPI by OHDSI.

the class ExceptionHandlingController method exceptionHandler.

@ExceptionHandler(IORuntimeException.class)
public ResponseEntity<JsonResult> exceptionHandler(IORuntimeException ex) {
    LOGGER.error(ex.getMessage(), ex);
    JsonResult result = new JsonResult<>(SYSTEM_ERROR);
    result.setErrorMessage(ex.getMessage());
    return new ResponseEntity<>(result, HttpStatus.OK);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) JsonResult(com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult) ExceptionHandler(org.springframework.web.bind.annotation.ExceptionHandler)

Example 95 with ExceptionHandler

use of org.springframework.web.bind.annotation.ExceptionHandler in project ArachneCentralAPI by OHDSI.

the class ExceptionHandlingController method exceptionHandler.

@ExceptionHandler(AccessDeniedException.class)
public ResponseEntity<JsonResult> exceptionHandler(AccessDeniedException ex) {
    LOGGER.error(ex.getMessage());
    JsonResult result = new JsonResult<>(PERMISSION_DENIED);
    result.setErrorMessage(ex.getMessage());
    return new ResponseEntity<>(result, HttpStatus.OK);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) JsonResult(com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult) ExceptionHandler(org.springframework.web.bind.annotation.ExceptionHandler)

Aggregations

ExceptionHandler (org.springframework.web.bind.annotation.ExceptionHandler)178 ResponseEntity (org.springframework.http.ResponseEntity)58 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)48 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)41 HttpHeaders (org.springframework.http.HttpHeaders)39 ModelAndView (org.springframework.web.servlet.ModelAndView)33 ResponseEntityExceptionHandler (org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler)31 JsonResult (com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult)17 HttpStatus (org.springframework.http.HttpStatus)13 AjaxJson (com.cdeledu.common.base.AjaxJson)12 ResultModels (eu.bcvsolutions.idm.core.api.dto.ResultModels)8 DefaultErrorModel (eu.bcvsolutions.idm.core.api.exception.DefaultErrorModel)8 ErrorModel (eu.bcvsolutions.idm.core.api.exception.ErrorModel)8 RestResponse (org.entando.entando.web.common.model.RestResponse)8 ArrayList (java.util.ArrayList)7 BindingResult (org.springframework.validation.BindingResult)6 FieldError (org.springframework.validation.FieldError)5 ErrorInfo (com.haulmont.restapi.exception.ErrorInfo)4 PrintWriter (java.io.PrintWriter)4 StringWriter (java.io.StringWriter)4