Skip to content

Commit

Permalink
bug #18812 Catch \Throwable (fprochazka)
Browse files Browse the repository at this point in the history
This PR was squashed before being merged into the 2.3 branch (closes #18812).

Discussion
----------

Catch \Throwable

| Q             | A
| ------------- | ---
| Branch?       | 2.3, 2.7, 2.8, 3.0
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | Yes
| Fixed tickets | n/a
| License       | MIT
| Doc PR        | n/a

Related #18765, #15949

Commits
-------

893cf00 Catch \Throwable
  • Loading branch information
nicolas-grekas committed May 30, 2016
2 parents 0cf017e + 893cf00 commit a60c355
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 3 deletions.
Expand Up @@ -77,6 +77,9 @@ public function load($resource, $type = null)
} catch (\Exception $e) {
$this->loading = false;
throw $e;
} catch (\Throwable $e) {
$this->loading = false;
throw $e;
}

$this->loading = false;
Expand All @@ -85,7 +88,7 @@ public function load($resource, $type = null)
if ($controller = $route->getDefault('_controller')) {
try {
$controller = $this->parser->parse($controller);
} catch (\Exception $e) {
} catch (\InvalidArgumentException $e) {
// unable to optimize unknown notation
}

Expand Down
Expand Up @@ -18,6 +18,7 @@
use Symfony\Component\HttpFoundation\Session\Flash\AutoExpireFlashBag;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Bundle\WebProfilerBundle\Profiler\TemplateManager;
use Symfony\Component\Routing\Exception\RouteNotFoundException;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;

/**
Expand Down Expand Up @@ -193,8 +194,8 @@ public function toolbarAction(Request $request, $token)
$url = null;
try {
$url = $this->generator->generate('_profiler', array('token' => $token));
} catch (\Exception $e) {
// the profiler is not enabled
} catch (RouteNotFoundException $e) {
// the named route doesn't exist => the profiler is not enabled
}

return new Response($this->twig->render('@WebProfiler/Profiler/toolbar.html.twig', array(
Expand Down
3 changes: 3 additions & 0 deletions src/Symfony/Component/Config/Loader/FileLoader.php
Expand Up @@ -108,6 +108,9 @@ public function import($resource, $type = null, $ignoreErrors = false, $sourceRe
} catch (\Exception $e) {
unset(self::$loading[$resource]);
throw $e;
} catch (\Throwable $e) {
unset(self::$loading[$resource]);
throw $e;
}

unset(self::$loading[$resource]);
Expand Down
5 changes: 5 additions & 0 deletions src/Symfony/Component/DependencyInjection/Container.php
Expand Up @@ -320,6 +320,11 @@ public function get($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE
return;
}

throw $e;
} catch (\Throwable $e) {
unset($this->loading[$id]);
unset($this->services[$id]);

throw $e;
}

Expand Down
Expand Up @@ -461,6 +461,10 @@ public function get($id, $invalidBehavior = ContainerInterface::EXCEPTION_ON_INV
return;
}

throw $e;
} catch (\Throwable $e) {
unset($this->loading[$id]);

throw $e;
}

Expand Down
Expand Up @@ -64,6 +64,11 @@ public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQ
$this->container->set('request', null, 'request');
$this->container->leaveScope('request');

throw $e;
} catch (\Throwable $e) {
$this->container->set('request', null, 'request');
$this->container->leaveScope('request');

throw $e;
}

Expand Down

0 comments on commit a60c355

Please sign in to comment.