Commit be1688e9 authored by Sascha Herzinger's avatar Sascha Herzinger
Browse files

added handlers for different exceptions

parent 40c4399d
Pipeline #11778 failed with stage
in 13 minutes and 2 seconds
......@@ -10,6 +10,7 @@ import org.apache.logging.log4j.Logger;
import org.springframework.http.*;
import org.springframework.http.converter.HttpMessageNotReadableException;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.web.HttpMediaTypeNotSupportedException;
import org.springframework.web.bind.MissingServletRequestParameterException;
import org.springframework.web.bind.ServletRequestBindingException;
import org.springframework.web.bind.annotation.ExceptionHandler;
......@@ -37,7 +38,11 @@ public abstract class BaseController {
} else if (e instanceof OperationNotAllowedException) {
return createErrorResponse("Operation not allowed.", e.getMessage(), new HttpHeaders(),
HttpStatus.METHOD_NOT_ALLOWED);
} else if (e instanceof QueryException || e instanceof HttpMessageNotReadableException || e instanceof MissingServletRequestParameterException) {
} else if (e instanceof QueryException
|| e instanceof HttpMessageNotReadableException
|| e instanceof MissingServletRequestParameterException
|| e instanceof HttpMediaTypeNotSupportedException
|| e instanceof IllegalArgumentException) {
logger.error(e, e);
return createErrorResponse("Query server error.", e.getMessage(), new HttpHeaders(), HttpStatus.BAD_REQUEST);
} else if (e instanceof ServletRequestBindingException && e.getMessage().contains(Configuration.AUTH_TOKEN)) {
......
......@@ -2,6 +2,7 @@ package lcsb.mapviewer.api.minervanet;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import lcsb.mapviewer.api.BaseController;
import lcsb.mapviewer.model.user.ConfigurationElementType;
import lcsb.mapviewer.services.interfaces.IConfigurationService;
import org.apache.http.HttpEntity;
......@@ -21,7 +22,7 @@ import java.io.IOException;
@RestController
@RequestMapping("/minervanet")
public class MinervaNetController {
public class MinervaNetController extends BaseController {
private Logger logger = LogManager.getLogger(MinervaNetController.class);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment