Commit 9542f52b authored by sgandhi@nisum.com's avatar sgandhi@nisum.com

EPE-006 : Added ccustomw exception

parent b8782293
......@@ -19,7 +19,7 @@ configurations {
repositories {
flatDir {
dirs 'C:\\Users\\abogari\\.m2\\repository\\com\\nisum\\exceptionservice\\0.0.1'
dirs '/Users/sivanagasomeswaragandhijatla/.m2/repository/com/nisum/exceptionservice/0.0.1'
// dirs '/Users/sivanagagasomeswaragandhijatla/.m2/repository/com/nisum/exceptionservice/0.0.1'
}
mavenCentral()
......
package com.nisum.offertransactionservice.handler;
import feign.FeignException;
import com.nisum.offertransactionservice.service.CustomCreatedCustomException;
import org.json.JSONObject;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
......@@ -11,9 +11,9 @@ import java.util.Map;
@RestControllerAdvice
public class FeignExceptionHandler {
@ExceptionHandler({FeignException.BadRequest.class,FeignException.InternalServerError.class,FeignException.NotFound.class})
public Map<String, Object> handleFeignStatusException(FeignException e, HttpServletResponse response) {
response.setStatus(e.status());
return new JSONObject(e.contentUTF8()).toMap();
@ExceptionHandler({CustomCreatedCustomException.class})
public Map<String, Object> handleFeignStatusException(CustomCreatedCustomException e, HttpServletResponse response) {
response.setStatus(e.getStatus());
return new JSONObject(e.getContentUTF8()).toMap();
}
}
package com.nisum.offertransactionservice.service;
import feign.FeignException;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class CustomCreatedCustomException extends RuntimeException{
private int status;
private String contentUTF8;
}
......@@ -9,6 +9,7 @@ import com.nisum.offertransactionservice.dao.OfferMetaDataRepo;
import com.nisum.offertransactionservice.dto.*;
import com.nisum.offertransactionservice.genericexception.GlobalApiGenericException;
import com.nisum.offertransactionservice.model.*;
import feign.FeignException;
import lombok.extern.slf4j.Slf4j;
import org.mapstruct.factory.Mappers;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -53,8 +54,15 @@ public class OfferCallingPEService {
OfferTransactionResponse offerTransactionResponse;
PERequest peRequest = INSTANCE.map(offerTransactionRequest);
peRequest.setEligibleOffers(offerLookupDTOList);
peRequest.setHhId(null);
log.info("Promotional Engine Feign client call Start");
ResponseEntity<PEResponse> peResponse = feignClientService.callPEService(peRequest);
ResponseEntity<PEResponse> peResponse = null;
try{
peResponse = feignClientService.callPEService(peRequest);
}catch (FeignException e){
throw new CustomCreatedCustomException(e.status(),e.contentUTF8());
}
log.debug("Promotional Engine Feign client call End");
offerTransactionResponse = INSTANCE.map(peResponse.getBody());
offerTransactionResponse.setTransactionId(offerTransactionRequest.getTransactionId());
......
Markdown is supported
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