File History: src/main/java/com/paymentlink/exception/GlobalExceptionHandler.java

← View file content

File Content at Commit 4617f76

1 package com.paymentlink.exception;
2
3 import org.slf4j.Logger;
4 import org.slf4j.LoggerFactory;
5 import org.springframework.http.HttpStatus;
6 import org.springframework.web.bind.annotation.ControllerAdvice;
7 import org.springframework.web.bind.annotation.ExceptionHandler;
8 import org.springframework.web.bind.annotation.ResponseStatus;
9 import org.springframework.web.servlet.ModelAndView;
10
11 @ControllerAdvice
12 public class GlobalExceptionHandler {
13
14 private static final Logger logger = LoggerFactory.getLogger(GlobalExceptionHandler.class);
15
16 @ExceptionHandler(RegionBlockedException.class)
17 @ResponseStatus(HttpStatus.FORBIDDEN)
18 public ModelAndView handleRegionBlocked(RegionBlockedException ex) {
19 logger.warn("Region blocked: {} ({})", ex.getCountryName(), ex.getCountryCode());
20
21 ModelAndView mav = new ModelAndView("region-blocked");
22 mav.addObject("countryCode", ex.getCountryCode());
23 mav.addObject("countryName", ex.getCountryName());
24 mav.addObject("message", "Service is not available in your region");
25
26 return mav;
27 }
28
29 @ExceptionHandler(Exception.class)
30 @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
31 public ModelAndView handleGenericException(Exception ex) {
32 logger.error("Unexpected error", ex);
33
34 ModelAndView mav = new ModelAndView("error");
35 mav.addObject("message", "An unexpected error occurred");
36 mav.addObject("error", ex.getMessage());
37
38 return mav;
39 }
40 }
41

Commits

Commit Author Date Message File SHA Actions
f0438c2 <f69e50@finnacloud.com> 1766443042 +0300 12/22/2025, 10:37:22 PM increment once more d400e7f View
188fc92 <f69e50@finnacloud.com> 1766442998 +0300 12/22/2025, 10:36:38 PM increment d400e7f View
4617f76 <f69e50@finnacloud.com> 1766442953 +0300 12/22/2025, 10:35:53 PM rename branch from main to master oops d400e7f Hide
e6d1548 <f69e50@finnacloud.com> 1766442769 +0300 12/22/2025, 10:32:49 PM add initial test workflow file d400e7f View
9c24ca4 <f69e50@finnacloud.com> 1766442705 +0300 12/22/2025, 10:31:45 PM add CI configuration and test script for Jenkins build d400e7f View
690c1f6 <f69e50@finnacloud.com> 1766368110 +0300 12/22/2025, 1:48:30 AM initialize backend structure with controllers, DTOs, and configuration files d400e7f View