handleException example

$logger
                ->expects($this->exactly(2))
                ->method('log')
                ->willReturnCallback($logArgCheck)
            ;

            $handler->setDefaultLogger($logger, \E_ERROR);
            $handler->setExceptionHandler(null);

            try {
                $handler->handleException($exception);
                $this->fail('Exception expected');
            } catch (\Throwable $e) {
                $this->assertInstanceOf($exception::class$e);
                $this->assertSame($enhancedMessage ?? $exception->getMessage()$e->getMessage());
            }

            $handler->setExceptionHandler(function D$e) use ($exception$enhancedMessage) {
                $this->assertInstanceOf($exception::class$e);
                $this->assertSame($enhancedMessage ?? $exception->getMessage()$e->getMessage());
            });

            
$this->message->display($message);
              }
            }
          }
          catch (MigrateException $e) {
            $this->getIdMap()->saveIdMapping($row[]$e->getStatus());
            $this->saveMessage($e->getMessage()$e->getLevel());
          }
          catch (\Exception $e) {
            $this->getIdMap()
              ->saveIdMapping($row[], MigrateIdMapInterface::STATUS_FAILED);
            $this->handleException($e);
          }
        }

        $this->sourceRowStatus = MigrateIdMapInterface::STATUS_IMPORTED;

        // Check for memory exhaustion.         if (($return = $this->checkStatus()) != MigrationInterface::RESULT_COMPLETED) {
          break;
        }

        // If anyone has requested we stop, return the requested result.
try {
            $request = new MetaRequest(
                $this->Request()->getParam('technicalName'),
                $this->getVersion(),
                $this->getDomain(),
                $this->getAccessToken()
            );

            $result = $this->get('shopware_plugininstaller.plugin_download_service')->getMetaInformation($request);
            $this->get('backendsession')->offsetSet('plugin_manager_meta_download', $result);
        } catch (Exception $e) {
            $this->handleException($e);

            return;
        }

        $this->View()->assign(['success' => true, 'data' => $result]);
    }

    /** * @return void */
    public function rangeDownloadAction()
    {
if (!$this->booted) {
        $this->initializeSettings($request);
        $this->boot();
      }
      $response = $this->getHttpKernel()->handle($request$type$catch);
    }
    catch (\Exception $e) {
      if ($catch === FALSE) {
        throw $e;
      }

      $response = $this->handleException($e$request$type);
    }

    // Adapt response headers to the current request.     $response->prepare($request);

    return $response;
  }

  /** * Converts an exception into a response. * * @param \Exception $e * An exception * @param \Symfony\Component\HttpFoundation\Request $request * A Request instance * @param int $type * The type of the request (one of HttpKernelInterface::MAIN_REQUEST or * HttpKernelInterface::SUB_REQUEST) * * @return \Symfony\Component\HttpFoundation\Response * A Response instance * * @throws \Exception * If the passed in exception cannot be turned into a response. */
if ($exception === $handlerException && null === $this->exceptionHandler) {
            self::$reservedMemory = null; // Disable the fatal error handler             throw $exception; // Give back $exception to the native handler         }

        $loggedErrors = $this->loggedErrors;
        if ($exception === $handlerException) {
            $this->loggedErrors &= ~$type;
        }

        try {
            $this->handleException($handlerException);
        } finally {
            $this->loggedErrors = $loggedErrors;
        }
    }

    /** * Shutdown registered function for handling PHP fatal errors. * * @param array|null $error An array as returned by error_get_last() * * @internal */
$request = new UpdateLicencesRequest(
            $this->getVersion(),
            $this->getLocale(),
            $accountService->getDomain(),
            $this->getAccessToken()
        );

        try {
            $result = $licenceService->updateLicences($request);
        } catch (Exception $e) {
            $this->handleException($e);

            return;
        }

        $plugins = $pluginCheck->checkInstalledPluginsAvailableForNewVersion($this->getVersion());

        $updatable = array_filter($pluginsfunction D$plugin) {
            return $plugin['updatable'];
        });

        $notUpdatable = array_filter($pluginsfunction D$plugin) {
            
'Enlight_Controller_Front_DispatchLoopShutdown' => ['onDispatchEvent', 100],
        ];
    }

    public function onDispatchEvent(EventArgs $args)
    {
        if (!$args->getResponse()->isException()) {
            return;
        }

        $exception = $args->getResponse()->getException();
        $this->handleException($exception[0]);
    }

    /** * @param Exception $exception * * @throws Exception */
    private function handleException($exception)
    {
        $request = new Enlight_Controller_Request_RequestHttp();
        $response = new Enlight_Controller_Response_ResponseHttp();

        
// The URL may be NULL if the source field is empty, which is invalid input.     if (empty($url)) {
      $this->context->addViolation($constraint->invalidResourceMessage);
      return;
    }

    // Ensure that the URL matches a provider.     try {
      $provider = $this->urlResolver->getProviderByUrl($url);
    }
    catch (ResourceException $e) {
      $this->handleException($e$constraint->unknownProviderMessage);
      return;
    }
    catch (ProviderException $e) {
      $this->handleException($e$constraint->providerErrorMessage);
      return;
    }

    // Ensure that the provider is allowed.     if (!in_array($provider->getName()$source->getProviders(), TRUE)) {
      $this->context->addViolation($constraint->disallowedProviderMessage, [
        '@name' => $provider->getName(),
      ]);
// Handle the actual request. We need the session both for authentication       // as well as the DB update, like       // \Drupal\system\Controller\DbUpdateController::batchFinished.       $this->bootSession($request);
      $result = $this->handleRaw($request);
      $this->shutdownSession($request);

      return $result;
    }
    catch (\Exception $e) {
      return $this->handleException($e$request$type);
    }
  }

  /** * Generates the actual result of update.php. * * The actual logic of the update is done in the db update controller. * * @param \Symfony\Component\HttpFoundation\Request $request * The incoming request. * * @return \Symfony\Component\HttpFoundation\Response * A response object. * * @see \Drupal\system\Controller\DbUpdateController */
if ($exception === $handlerException && null === $this->exceptionHandler) {
            self::$reservedMemory = null; // Disable the fatal error handler             throw $exception; // Give back $exception to the native handler         }

        $loggedErrors = $this->loggedErrors;
        if ($exception === $handlerException) {
            $this->loggedErrors &= ~$type;
        }

        try {
            $this->handleException($handlerException);
        } finally {
            $this->loggedErrors = $loggedErrors;
        }
    }

    /** * Shutdown registered function for handling PHP fatal errors. * * @param array|null $error An array as returned by error_get_last() * * @internal */
throw RoutingException::missingRequestParameter('_sw_payment_token');
        }

        $salesChannelContext = $this->assembleSalesChannelContext($paymentToken);

        $result = $this->paymentService->finalizeTransaction(
            $paymentToken,
            $request,
            $salesChannelContext
        );

        $response = $this->handleException($result);
        if ($response !== null) {
            return $response;
        }

        $finishUrl = $result->getFinishUrl();
        if ($finishUrl) {
            return new RedirectResponse($finishUrl);
        }

        return new JsonResponse(null, Response::HTTP_NO_CONTENT);
    }

    
Home | Imprint | This part of the site doesn't use cookies.