Java back-end server programming; includes various exercises
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

33 lines
1001 B

// Pekka Helenius <fincer89@hotmail.com>, Fjordtek 2020
package com.fjordtek.chapter2_task3_friendlist.web;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.ExceptionHandler;
import javax.servlet.http.HttpServletRequest;
@ControllerAdvice
public class HttpExceptionHandler {
private static final String HTTPNOTFOUND = "Invalid request";
private HttpServerLogger httpServerLogger = new HttpServerLogger();
@ResponseStatus(
value = HttpStatus.NOT_FOUND,
reason = HTTPNOTFOUND
)
// Very simple exception handler (not any sophistication)
@ExceptionHandler(Exception.class)
public String notFoundErrorHandler(HttpServletRequest requestData) {
httpServerLogger.logMessageError(
requestData,
"HTTPNOTFOUND"
);
return "error";
}
}