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