|
10 | 10 | import com.openbankproject.hydra.auth.util.PKCEUtil; |
11 | 11 | import com.openbankproject.model.*; |
12 | 12 | import org.apache.commons.lang3.ArrayUtils; |
| 13 | +import org.apache.commons.lang3.StringUtils; |
13 | 14 | import org.slf4j.Logger; |
14 | 15 | import org.slf4j.LoggerFactory; |
15 | 16 | import org.springframework.beans.factory.annotation.Autowired; |
@@ -370,6 +371,15 @@ public String requestConsents(@RequestParam("bank") String bankId, |
370 | 371 | SessionData.remoteUserInfo(session); |
371 | 372 |
|
372 | 373 | return redirectUrl; |
| 374 | + } catch (HttpStatusCodeException httpException) { |
| 375 | + logger.error("Error: ", httpException); |
| 376 | + String errorDetail = httpException.getStatusCode() + " " + httpException.getStatusText(); |
| 377 | + String responseBody = httpException.getResponseBodyAsString(); |
| 378 | + if (StringUtils.isNotBlank(responseBody)) { |
| 379 | + errorDetail += " - " + responseBody; |
| 380 | + } |
| 381 | + model.addAttribute("errorMsg", errorDetail); |
| 382 | + return "error"; |
373 | 383 | } catch (Exception unhandledException) { |
374 | 384 | logger.error("Error: ", unhandledException); |
375 | 385 | if(showUnhandledErrors) model.addAttribute("errorMsg", unhandledException); |
@@ -619,6 +629,15 @@ public String requestConsentsBerlinGroup(@RequestParam("bank") String bankId, |
619 | 629 | SessionData.remoteUserInfo(session); |
620 | 630 |
|
621 | 631 | return redirectUrl; |
| 632 | + } catch (HttpStatusCodeException httpException) { |
| 633 | + logger.error("Error: ", httpException); |
| 634 | + String errorDetail = httpException.getStatusCode() + " " + httpException.getStatusText(); |
| 635 | + String responseBody = httpException.getResponseBodyAsString(); |
| 636 | + if (StringUtils.isNotBlank(responseBody)) { |
| 637 | + errorDetail += " - " + responseBody; |
| 638 | + } |
| 639 | + model.addAttribute("errorMsg", errorDetail); |
| 640 | + return "error"; |
622 | 641 | } catch (Exception unhandledException) { |
623 | 642 | logger.error("Error: ", unhandledException); |
624 | 643 | if(showUnhandledErrors) model.addAttribute("errorMsg", unhandledException); |
@@ -738,6 +757,15 @@ public String requestConsentsOpenBankProject(@RequestParam("bank") String bankId |
738 | 757 | SessionData.remoteUserInfo(session); |
739 | 758 |
|
740 | 759 | return redirectUrl; |
| 760 | + } catch (HttpStatusCodeException httpException) { |
| 761 | + logger.error("Error: ", httpException); |
| 762 | + String errorDetail = httpException.getStatusCode() + " " + httpException.getStatusText(); |
| 763 | + String responseBody = httpException.getResponseBodyAsString(); |
| 764 | + if (StringUtils.isNotBlank(responseBody)) { |
| 765 | + errorDetail += " - " + responseBody; |
| 766 | + } |
| 767 | + model.addAttribute("errorMsg", errorDetail); |
| 768 | + return "error"; |
741 | 769 | } catch (Exception unhandledException) { |
742 | 770 | logger.error("Error: ", unhandledException); |
743 | 771 | if(showUnhandledErrors) model.addAttribute("errorMsg", unhandledException); |
@@ -878,6 +906,15 @@ public String requestConsentsVrpOpenBankProject(@RequestParam("bank") String ban |
878 | 906 | SessionData.remoteUserInfo(session); |
879 | 907 |
|
880 | 908 | return redirectUrl; |
| 909 | + } catch (HttpStatusCodeException httpException) { |
| 910 | + logger.error("Error: ", httpException); |
| 911 | + String errorDetail = httpException.getStatusCode() + " " + httpException.getStatusText(); |
| 912 | + String responseBody = httpException.getResponseBodyAsString(); |
| 913 | + if (StringUtils.isNotBlank(responseBody)) { |
| 914 | + errorDetail += " - " + responseBody; |
| 915 | + } |
| 916 | + model.addAttribute("errorMsg", errorDetail); |
| 917 | + return "error"; |
881 | 918 | } catch (Exception unhandledException) { |
882 | 919 | logger.error("Error: ", unhandledException); |
883 | 920 | if(showUnhandledErrors) model.addAttribute("errorMsg", unhandledException); |
@@ -943,6 +980,15 @@ public String administrateConsents(@RequestParam("bank") String bankId, HttpSess |
943 | 980 | SessionData.remoteUserInfo(session); |
944 | 981 |
|
945 | 982 | return redirectUrl; |
| 983 | + } catch (HttpStatusCodeException httpException) { |
| 984 | + logger.error("Error: ", httpException); |
| 985 | + String errorDetail = httpException.getStatusCode() + " " + httpException.getStatusText(); |
| 986 | + String responseBody = httpException.getResponseBodyAsString(); |
| 987 | + if (StringUtils.isNotBlank(responseBody)) { |
| 988 | + errorDetail += " - " + responseBody; |
| 989 | + } |
| 990 | + model.addAttribute("errorMsg", errorDetail); |
| 991 | + return "error"; |
946 | 992 | } catch (Exception unhandledException) { |
947 | 993 | logger.error("Error: ", unhandledException); |
948 | 994 | if(showUnhandledErrors) model.addAttribute("errorMsg", unhandledException); |
|
0 commit comments