wisemapping-open-source/wise-webapp/src/main/java/com/wisemapping/rest/BaseController.java

28 lines
814 B
Java
Raw Normal View History

package com.wisemapping.rest;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;
public class BaseController {
@ExceptionHandler(IllegalArgumentException.class)
@ResponseStatus(HttpStatus.BAD_REQUEST)
@ResponseBody
public String handleClientErrors(Exception ex) {
ex.printStackTrace();
return ex.getMessage();
}
@ExceptionHandler(Exception.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
@ResponseBody
public String handleServerErrors(Exception ex) {
ex.printStackTrace();
// LOGGER.error(ex.getMessage(), ex);
return ex.getMessage();
}
}