+ /**
+ * Show in-page exception
+ * For situations where where calling abend will block the ability for a branded error screen
+ *
+ * Although the host page will run past this point, CiviCRM should not,
+ * therefore we trigger the civi.exit events
+ *
+ * @param string $code
+ */
+ protected static function inpageExceptionDisplay($code) {
+ // do a hard rollback of any pending transactions
+ // if we've come here, its because of some unexpected PEAR errors
+ CRM_Core_Transaction::forceRollbackIfEnabled();
+
+ if ($code > 0 && !headers_sent()) {
+ http_response_code(500);
+ }
+
+ // move things to CiviCRM cache as needed
+ CRM_Core_Session::storeSessionObjects();
+
+ if (Civi\Core\Container::isContainerBooted()) {
+ Civi::dispatcher()->dispatch('civi.core.exit');
+ }
+
+ $userSystem = CRM_Core_Config::singleton()->userSystem;
+ if (is_callable([$userSystem, 'onCiviExit'])) {
+ $userSystem->onCiviExit();
+ }
+ }
+