Remove unused parameters from BaseIPN->cancelled signature
[civicrm-core.git] / CRM / Core / Exception.php
CommitLineData
6a488035 1<?php
6a488035
TO
2/*
3 +--------------------------------------------------------------------+
bc77d7c0 4 | Copyright CiviCRM LLC. All rights reserved. |
6a488035 5 | |
bc77d7c0
TO
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 |
6a488035 9 +--------------------------------------------------------------------+
d25dd0ee 10 */
6a488035
TO
11
12/**
13 * Base class for exceptions generated by CiviCRM.
dcc4f6a7 14 * This Exception returns more information than the default one. We are using it from the
15 * form layer to allow redirects to occur without having redirects in the BAO
6a0b768e
TO
16 * @param string $message
17 * The human friendly error message.
18 * @param string $error_code
19 * A computer friendly error code. By convention, no space (but underscore allowed).
16b10e64 20 * ex: mandatory_missing, duplicate, invalid_format
6a0b768e
TO
21 * @param array $data
22 * Extra params to return. eg an extra array of ids. It is not mandatory, but can help the computer using the api. Keep in mind the api consumer isn't to be trusted. eg. the database password is NOT a good extra data.
6a488035
TO
23 */
24class CRM_Core_Exception extends PEAR_Exception {
be2fb01f 25 private $errorData = [];
a0ee3941
EM
26
27 /**
70599df6 28 * Class constructor.
29 *
30 * @param string $message
a0ee3941
EM
31 * @param int $error_code
32 * @param array $errorData
33 * @param null $previous
34 */
be2fb01f 35 public function __construct($message, $error_code = 0, $errorData = [], $previous = NULL) {
1836ab9e 36 parent::__construct($message);
be2fb01f 37 $this->errorData = $errorData + ['error_code' => $error_code];
dcc4f6a7 38 }
39
a0ee3941 40 /**
70599df6 41 * Custom string representation of object.
42 *
a0ee3941
EM
43 * @return string
44 */
dcc4f6a7 45 public function __toString() {
46 return __CLASS__ . ": [{$this->errorData['error_code']}: {$this->message}\n";
47 }
48
70599df6 49 /**
50 * Get error code.
51 *
52 * @return mixed
53 */
dcc4f6a7 54 public function getErrorCode() {
55 return $this->errorData['error_code'];
56 }
b5c2afd0
EM
57
58 /**
70599df6 59 * Return specific error information.
60 *
61 * (Can be used for more detailed error messages or translation.)
b5c2afd0
EM
62 *
63 * This method may be overridden in child exception classes in order
64 * to add functionality not present in PEAR_Exception and is a placeholder
65 * to define API
66 *
67 * The returned array must be an associative array of parameter => value like so:
68 * <pre>
69 * array('name' => $name, 'context' => array(...))
70 * </pre>
71 * @return array
72 */
dcc4f6a7 73 public function getErrorData() {
74 return $this->errorData;
75 }
96025800 76
6a488035 77}