com.payu.common.client.handler.ResourceConflictHandler Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ms-common-client Show documentation
Show all versions of ms-common-client Show documentation
Librairie commune pour les modules MS Clients
package com.payu.common.client.handler;
import com.payu.common.client.error.ApiError;
import com.payu.common.client.exception.ResourceConflictException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
/** Handler des exceptions @{@link ResourceConflictException} */
@ControllerAdvice
@Slf4j
@Order(Ordered.HIGHEST_PRECEDENCE)
public class ResourceConflictHandler extends AbstractErrorHandler {
/**
* @param exception exception traitant les ressources duplique en base
* @return une 404 enrichit avec l'erreur reformatée
*/
@ExceptionHandler({ResourceConflictException.class})
public ResponseEntity handleConflictExceptions(ResourceConflictException exception) {
// log.warn("Ressource introuvable : {}", exception.getLocalizedMessage(), exception);
log.warn("{}", exception.getLocalizedMessage());
return new ResponseEntity<>(
createApiError(exception, exception.getCode(), HttpStatus.CONFLICT), HttpStatus.CONFLICT);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy