Skip to content

Commit

Permalink
Merge branch '3.0' into 3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
wouterj committed Jun 12, 2016
2 parents f19328b + bfcafee commit a01f87f
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 33 deletions.
6 changes: 3 additions & 3 deletions book/http_cache.rst
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ as `Varnish`_, `Squid in reverse proxy mode`_, and the Symfony reverse proxy.
Types of Caches
~~~~~~~~~~~~~~~

But a gateway cache isn't the only type of cache. In fact, the HTTP cache
headers sent by your application are consumed and interpreted by up to three
different types of caches:
A gateway cache isn't the only type of cache. In fact, the HTTP cache headers
sent by your application are consumed and interpreted by up to three different
types of caches:

* *Browser caches*: Every browser comes with its own local cache that is
mainly useful for when you hit "back" or for images and other assets.
Expand Down
60 changes: 30 additions & 30 deletions components/console/events.rst
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,36 @@ C/C++ standard.::
}
});

The ``ConsoleEvents::EXCEPTION`` Event
--------------------------------------

**Typical Purposes**: Handle exceptions thrown during the execution of a
command.

Whenever an exception is thrown by a command, the ``ConsoleEvents::EXCEPTION``
event is dispatched. A listener can wrap or change the exception or do
anything useful before the exception is thrown by the application.

Listeners receive a
:class:`Symfony\\Component\\Console\\Event\\ConsoleExceptionEvent` event::

use Symfony\Component\Console\Event\ConsoleExceptionEvent;
use Symfony\Component\Console\ConsoleEvents;

$dispatcher->addListener(ConsoleEvents::EXCEPTION, function (ConsoleExceptionEvent $event) {
$output = $event->getOutput();

$command = $event->getCommand();

$output->writeln(sprintf('Oops, exception thrown while running command <info>%s</info>', $command->getName()));

// get the current exit code (the exception code or the exit code set by a ConsoleEvents::TERMINATE event)
$exitCode = $event->getExitCode();

// change the exception to another one
$event->setException(new \LogicException('Caught exception', $exitCode, $event->getException()));
});

The ``ConsoleEvents::TERMINATE`` Event
--------------------------------------

Expand Down Expand Up @@ -121,34 +151,4 @@ Listeners receive a
It is then dispatched just after the ``ConsoleEvents::EXCEPTION`` event.
The exit code received in this case is the exception code.

The ``ConsoleEvents::EXCEPTION`` Event
--------------------------------------

**Typical Purposes**: Handle exceptions thrown during the execution of a
command.

Whenever an exception is thrown by a command, the ``ConsoleEvents::EXCEPTION``
event is dispatched. A listener can wrap or change the exception or do
anything useful before the exception is thrown by the application.

Listeners receive a
:class:`Symfony\\Component\\Console\\Event\\ConsoleExceptionEvent` event::

use Symfony\Component\Console\Event\ConsoleExceptionEvent;
use Symfony\Component\Console\ConsoleEvents;

$dispatcher->addListener(ConsoleEvents::EXCEPTION, function (ConsoleExceptionEvent $event) {
$output = $event->getOutput();

$command = $event->getCommand();

$output->writeln(sprintf('Oops, exception thrown while running command <info>%s</info>', $command->getName()));

// get the current exit code (the exception code or the exit code set by a ConsoleEvents::TERMINATE event)
$exitCode = $event->getExitCode();

// change the exception to another one
$event->setException(new \LogicException('Caught exception', $exitCode, $event->getException()));
});

.. _`reserved exit codes`: http://www.tldp.org/LDP/abs/html/exitcodes.html

0 comments on commit a01f87f

Please sign in to comment.