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