/*
* ============LICENSE_START=======================================================
* Copyright (C) 2020 Pantheon.tech
+ * Copyright (C) 2021 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import org.onap.cps.rest.controller.DataRestController;
import org.onap.cps.rest.controller.QueryRestController;
import org.onap.cps.rest.model.ErrorMessage;
+import org.onap.cps.spi.exceptions.AlreadyDefinedException;
import org.onap.cps.spi.exceptions.CpsAdminException;
import org.onap.cps.spi.exceptions.CpsException;
import org.onap.cps.spi.exceptions.CpsPathException;
QueryRestController.class})
public class CpsRestExceptionHandler {
- private static final String CHECK_LOGS_FOR_DETAILS = "Check logs for details.";
-
private CpsRestExceptionHandler() {
}
* @return response with response code 500.
*/
@ExceptionHandler
- public static ResponseEntity<Object> handleInternalServerErrorExceptions(
- final Exception exception) {
+ public static ResponseEntity<Object> handleInternalServerErrorExceptions(final Exception exception) {
return buildErrorResponse(HttpStatus.INTERNAL_SERVER_ERROR, exception);
}
return buildErrorResponse(HttpStatus.NOT_FOUND, exception);
}
- @ExceptionHandler({DataInUseException.class})
+ @ExceptionHandler({DataInUseException.class, AlreadyDefinedException.class})
public static ResponseEntity<Object> handleDataInUseException(final CpsException exception) {
return buildErrorResponse(HttpStatus.CONFLICT, exception);
}
errorMessage.setStatus(status.toString());
errorMessage.setMessage(exception.getMessage());
errorMessage.setDetails(exception instanceof CpsException ? ((CpsException) exception).getDetails() :
- CHECK_LOGS_FOR_DETAILS);
+ "Check logs for details.");
return new ResponseEntity<>(errorMessage, status);
}
}