wisemapping-open-source/wise-webapp/src/main/java/com/wisemapping/rest/BaseController.java
2012-02-25 11:56:20 -03:00

29 lines
874 B
Java

package com.wisemapping.rest;
import org.jetbrains.annotations.NotNull;
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(@NotNull Exception ex) {
ex.printStackTrace();
return ex.getMessage();
}
@ExceptionHandler(Exception.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
@ResponseBody
public String handleServerErrors(@NotNull Exception ex) {
ex.printStackTrace();
// LOGGER.error(ex.getMessage(), ex);
return ex.getMessage();
}
}