3b95ea539b1de53a5071d86dd5ba91f293bc3ebe
[civicrm-core.git] / Civi / API / Event / ExceptionEvent.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
5 | |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
10 */
11
12 namespace Civi\API\Event;
13
14 /**
15 * Handle any exceptions that occur while processing an API request.
16 *
17 * Event name: 'civi.api.exception'
18 */
19 class ExceptionEvent extends Event {
20
21 /**
22 * @var \Exception
23 */
24 private $exception;
25
26 /**
27 * @param \Exception $exception
28 * The exception which arose while processing the API request.
29 * @param \Civi\API\Provider\ProviderInterface $apiProvider
30 * The API provider responsible for executing the request.
31 * @param array $apiRequest
32 * The full description of the API request.
33 * @param \Civi\API\Kernel $apiKernel
34 * The kernel which fired the event.
35 */
36 public function __construct($exception, $apiProvider, $apiRequest, $apiKernel) {
37 $this->exception = $exception;
38 parent::__construct($apiProvider, $apiRequest, $apiKernel);
39 }
40
41 /**
42 * @return \Exception
43 */
44 public function getException() {
45 return $this->exception;
46 }
47
48 }