/** * Exception handler for the WFRequestController. * * This is basically the uncaught exception handler for the request cycle. * We want to have this in the request object because we want the result to be displayed within our skin system. * This function will display the appropriate error page based on the deployment mode for this machine. * * @param Exception The exception object to handle. */ function handleException(Exception $e) { // give ourselves a little more memory so we can process the exception ini_set('memory_limit', memory_get_usage() + 25000000); // grab error_get_last ASAP so that it cannot get adulterated by other things. // we will inject it into things downstream that want it. $standardErrorData = WFExceptionReporting::generatedStandardizedErrorDataFromException($e); // let the current module try to handle the exception if ($this->rootModuleInvocation) { $this->rootModuleInvocation->handleUncaughtException($e); } $webAppDelegate = WFWebApplication::sharedWebApplication()->delegate(); if (is_object($webAppDelegate) && method_exists($webAppDelegate, 'handleUncaughtException')) { $handled = $webAppDelegate->handleUncaughtException($e); if ($handled) { return; } } WFExceptionReporting::log($standardErrorData); $exceptionPage = new WFSmarty(); // LEGACY tpl var setup (in case there are old .tpl's that expect it // build stack of errors (php 5.3+) if (method_exists($e, 'getPrevious')) { $tmpE = $e; $allExceptions = array(); do { $allExceptions[] = $tmpE; } while ($tmpE = $tmpE->getPrevious()); } else { $allExceptions = array($e); } $exceptionPage->assign('exceptions', $allExceptions); $exceptionPage->assign('exceptionClass', get_class($allExceptions[0])); $exceptionPage->assign('home_url', WWW_ROOT . '/'); // end LEGACY // modern format $exceptionPage->assign('location', "http://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"); $exceptionPage->assign('headline', "{$standardErrorData[0]['title']}: {$standardErrorData[0]['message']}"); $exceptionPage->assign('standardErrorData', $standardErrorData); $exceptionPage->assign('standardErrorDataJSON', WFJSON::encode(array('error' => $standardErrorData, '$_SERVER' => $_SERVER, '$_REQUEST' => $_REQUEST, '$_SESSION' => $_SESSION))); if (IS_PRODUCTION) { $exceptionPage->setTemplate(WFWebApplication::appDirPath(WFWebApplication::DIR_SMARTY) . '/app_error_user.tpl'); } else { $exceptionPage->setTemplate(WFWebApplication::appDirPath(WFWebApplication::DIR_SMARTY) . '/app_error_developer.tpl'); } // display the error $body_html = $exceptionPage->render(false); // output error info header("HTTP/1.0 500 Uncaught Exception"); if ($this->isAjax()) { print strip_tags($body_html); } else { $skin = new WFSkin(); $skin->setDelegateName(WFWebApplication::sharedWebApplication()->defaultSkinDelegate()); $skin->setBody($body_html); $skin->setTitle("An error has occurred."); $skin->render(); } }
/** * Exception handler for the WFRequestController. * * This is basically the uncaught exception handler for the request cycle. * We want to have this in the request object because we want the result to be displayed within our skin system. * This function will display the appropriate error page based on the deployment mode for this machine, then exit. * * @param Exception The exception object to handle. */ function handleException(Exception $e) { // give ourselves a little more memory so we can process the exception ini_set('memory_limit', memory_get_usage() + 25000000); $webAppDelegate = WFWebApplication::sharedWebApplication()->delegate(); if (is_object($webAppDelegate) && method_exists($webAppDelegate, 'handleUncaughtException')) { $handled = $webAppDelegate->handleUncaughtException($e); if ($handled) { return; } } WFExceptionReporting::log($e); // build stack of errors (php 5.3+) if (method_exists($e, 'getPrevious')) { $allExceptions = array(); do { $allExceptions[] = $e; } while ($e = $e->getPrevious()); } else { $allExceptions = array($e); } $exceptionPage = new WFSmarty(); $exceptionPage->assign('exceptions', $allExceptions); $exceptionPage->assign('exceptionClass', get_class($allExceptions[0])); $exceptionPage->assign('home_url', WWW_ROOT . '/'); if (IS_PRODUCTION) { $exceptionPage->setTemplate(WFWebApplication::appDirPath(WFWebApplication::DIR_SMARTY) . '/app_error_user.tpl'); } else { $exceptionPage->setTemplate(WFWebApplication::appDirPath(WFWebApplication::DIR_SMARTY) . '/app_error_developer.tpl'); } // display the error and exit $body_html = $exceptionPage->render(false); // output error info header("HTTP/1.0 500 Uncaught Exception"); if ($this->isAjax()) { print strip_tags($body_html); } else { $skin = new WFSkin(); $skin->setDelegateName(WFWebApplication::sharedWebApplication()->defaultSkinDelegate()); $skin->setBody($body_html); $skin->setTitle("An error has occurred."); $skin->render(); } exit; }