Commit | Line | Data |
---|---|---|
665b4982 EM |
1 | <?php |
2 | ||
3 | class CRM_Core_LegacyErrorHandler { | |
4caeca04 TO |
4 | /** |
5 | * @param \Civi\Core\Event\UnhandledExceptionEvent $event | |
6 | * @throws Exception | |
7 | */ | |
8 | static function handleException($event) { | |
9 | $e = $event->exception; | |
665b4982 EM |
10 | if ($e instanceof CRM_Core_Exception) { |
11 | $params = $e->getErrorData(); | |
12 | $message = $e->getMessage(); | |
13 | $session = CRM_Core_Session::singleton(); | |
14 | $session->setStatus( | |
15 | $message, | |
16 | CRM_Utils_Array::value('message_title', $params), | |
17 | CRM_Utils_Array::value('message_type', $params, 'error') | |
18 | ); | |
19 | ||
20 | // @todo remove this code - legacy redirect path is an interim measure for moving redirects out of BAO | |
21 | // to somewhere slightly more acceptable. they should not be part of the exception class & should | |
22 | // be managed @ the form level - if you find a form that is triggering this piece of code | |
23 | // you should log a ticket for it to be removed with details about the form you were on. | |
24 | if (!empty($params['legacy_redirect_path'])) { | |
25 | if (CRM_Utils_System::isDevelopment()) { | |
26 | // here we could set a message telling devs to log it per above | |
27 | } | |
28 | CRM_Utils_System::redirect($params['legacy_redirect_path'], $params['legacy_redirect_query']); | |
29 | } | |
30 | } | |
31 | } | |
4caeca04 | 32 | |
665b4982 | 33 | } |