Login leads to Exeception, if the contract does not exist

Created on 2 April 2024, over 1 year ago
Updated 16 April 2024, over 1 year ago

Problem/Motivation

When logging in with a contract that has no Billwerk contract, the following exception appears:

GuzzleHttp\Exception\ClientException: Client error: `GET https://sandbox.billwerk.com/api/v1/contracts/66xxxxxxxxxxxxxx206` resulted in a `404 Not Found` response: {"Message":"Contract with Id '66xxxxxxxxxxxxxx206' does not exist."} in GuzzleHttp\Exception\RequestException::create() (line 113 of /guzzlehttp/guzzle/src/Exception/RequestException.php).

GuzzleHttp\Middleware::GuzzleHttp\{closure}() (Line: 209)
GuzzleHttp\Promise\Promise::callHandler() (Line: 158)
GuzzleHttp\Promise\Promise::GuzzleHttp\Promise\{closure}() (Line: 52)
GuzzleHttp\Promise\TaskQueue->run() (Line: 251)
GuzzleHttp\Promise\Promise->invokeWaitFn() (Line: 227)
GuzzleHttp\Promise\Promise->waitIfPending() (Line: 272)
GuzzleHttp\Promise\Promise->invokeWaitList() (Line: 229)
GuzzleHttp\Promise\Promise->waitIfPending() (Line: 69)
GuzzleHttp\Promise\Promise->wait() (Line: 189)
GuzzleHttp\Client->request() (Line: 44)
GuzzleHttp\Client->get() (Line: 179)
Drupal\billwerk_subscriptions\Api->get() (Line: 479)
Drupal\billwerk_subscriptions\Api->getContract() (Line: 38)
Drupal\billwerk_subscriptions\BillwerkDataObjectFactory->billwerkLoadBillwerkContract() (Line: 479)
Drupal\billwerk_subscriptions\Subscriber->getBillwerkContract() (Line: 71)
Drupal\billwerk_subscriptions_handler_default\EventSubscriber\SubscriberRefreshUserSubscriber->updateUserData() (Line: 52)
Drupal\billwerk_subscriptions_handler_default\EventSubscriber\SubscriberRefreshUserSubscriber->onSubscriberRefreshUser()
call_user_func() (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch() (Line: 153)
Drupal\billwerk_subscriptions\Subscriber->refreshFromBillwerkContractSubscription() (Line: 23)
billwerk_subscriptions_handler_default_user_login()
call_user_func_array() (Line: 409)
Drupal\Core\Extension\ModuleHandler->Drupal\Core\Extension\{closure}() (Line: 388)
Drupal\Core\Extension\ModuleHandler->invokeAllWith() (Line: 408)
Drupal\Core\Extension\ModuleHandler->invokeAll() (Line: 470)
user_login_finalize() (Line: 165)
Drupal\user\Form\UserLoginForm->submitForm()
call_user_func_array() (Line: 129)
Drupal\Core\Form\FormSubmitter->executeSubmitHandlers() (Line: 67)
Drupal\Core\Form\FormSubmitter->doSubmitForm() (Line: 597)
Drupal\Core\Form\FormBuilder->processForm() (Line: 325)
Drupal\Core\Form\FormBuilder->buildForm() (Line: 73)
Drupal\Core\Controller\FormController->getContentResult()
call_user_func_array() (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 627)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 121)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 58)
Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle() (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 45)
Drupal\services\StackMiddleware\FormatSetter->handle() (Line: 50)
Drupal\ban\BanMiddleware->handle() (Line: 270)
Drupal\shield\ShieldMiddleware->bypass() (Line: 169)
Drupal\shield\ShieldMiddleware->handle() (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 36)
Drupal\Core\StackMiddleware\AjaxPageState->handle() (Line: 49)
Drupal\remove_http_headers\StackMiddleware\RemoveHttpHeadersMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 704)
Drupal\Core\DrupalKernel->handle() (Line: 19)

Steps to reproduce

Proposed resolution

Instead this should just get logged and an error could be shown, but no exception.

So catch the exception.

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

🇩🇪Germany Anybody Porta Westfalica

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024