Merge pull request #15572 from civicrm/5.19
[civicrm-core.git] / CRM / Core / Exception / PrematureExitException.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2019 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
9 | |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
13 | |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
18 | |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
26 */
27
28 /**
29 * Exception thrown during tests where live code would exit.
30 *
31 * This is when the code would exit in live mode.
32 *
33 * @param string $message
34 * The human friendly error message.
35 * @param string $error_code
36 * A computer friendly error code. By convention, no space (but underscore allowed).
37 * ex: mandatory_missing, duplicate, invalid_format
38 * @param array $data
39 * Extra params to return. eg an extra array of ids. It is not mandatory, but can help the computer using the api.
40 * Keep in mind the api consumer isn't to be trusted. eg. the database password is NOT a good extra data.
41 */
42 class CRM_Core_Exception_PrematureExitException extends RuntimeException {
43
44 /**
45 * Construct the exception. Note: The message is NOT binary safe.
46 *
47 * @link https://php.net/manual/en/exception.construct.php
48 *
49 * @param string $message [optional] The Exception message to throw.
50 * @param array $errorData
51 * @param int $error_code
52 * @param throwable $previous [optional] The previous throwable used for the exception chaining.
53 */
54 public function __construct($message = "", $errorData = [], $error_code = 0, throwable $previous = NULL) {
55 parent::__construct($message, $error_code, $previous);
56 $this->errorData = $errorData + ['error_code' => $error_code];
57 }
58
59 }