All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.payu.common.client.handler.ResourceConflictHandler Maven / Gradle / Ivy

There is a newer version: 0.0.7
Show newest version
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