for the review

This commit is contained in:
himanshu
2025-10-28 15:46:31 +05:30
parent 4d501f7b4a
commit 92e71695a5
24 changed files with 331 additions and 284 deletions
@@ -1,29 +1,36 @@
package com.billpaymentservice.bbps.exception;
import com.billpaymentservice.bbps.dto.ResponseModel;
import com.billpaymentservice.bbps.dto.GeneralResp;
public class CustomException extends RuntimeException {
private static final long serialVersionUID = 1L;
private final GeneralResp generalResp;
public CustomException(String statusCode, String status,String message,String remark) {
private final ResponseModel responseModel;
public CustomException(String message, String status, int statusCode, String remarks) {
super(message);
this.generalResp = new GeneralResp();
this.generalResp.setStatusCode(statusCode);
this.generalResp.setStatus(status);
this.generalResp.setMessage(message);
this.generalResp.setRemarks(remark);
this.responseModel = new ResponseModel();
this.responseModel.setMessage(message);
this.responseModel.setStatus(status);
this.responseModel.setStatusCode(statusCode);
this.responseModel.setData(null);
this.responseModel.setDuplicateData(remarks);
}
public ResponseModel getResponseModel() {
return responseModel;
}
public CustomException(String message) {
super(message);
this.generalResp = new GeneralResp();
this.generalResp.setStatusCode("500");
this.generalResp.setStatus("Failure");
this.generalResp.setMessage(message);
this.generalResp.setRemarks("");
}
public GeneralResp getGeneralResp() {
return generalResp;
this.responseModel = new ResponseModel();
this.responseModel.setMessage(message);
this.responseModel.setStatus("FAILED");
this.responseModel.setStatusCode(400);
this.responseModel.setData(null);
this.responseModel.setDuplicateData(null);
}
}
@@ -5,12 +5,13 @@ import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import com.billpaymentservice.bbps.dto.GeneralResp;
import com.billpaymentservice.bbps.dto.ResponseModel;
@ControllerAdvice
public class GlobalExceptionHandler {
@ExceptionHandler(CustomException.class)
public ResponseEntity<GeneralResp> handleCustomException(CustomException ex) {
return new ResponseEntity<>(ex.getGeneralResp(), HttpStatus.INTERNAL_SERVER_ERROR);
public ResponseEntity<ResponseModel> handleCustomException(CustomException ex) {
return new ResponseEntity<>(ex.getResponseModel(), HttpStatus.BAD_REQUEST);
}
}
}