grthtrhthjhtyjytjytkergtrhtrjytjerhrfh4:24 29/09/2026throwable = $throwable; $this->query = $query; } /** * Shows the proper error message. * * If developer mode is enabled, a full exception page will be shown. */ public function handle() { global $sugar_config; $logger = new SuiteLogger(); $prefix = '[SearchThrowableHandler] '; $logger->error($prefix . $this->getFriendlyMessage()); $logger->error($prefix . $this->throwable); if ($sugar_config['developerMode'] === true) { $this->printStackTrace(); return; } $this->printFriendlyMessage(); } /** * Returns an error message that is user friendly. * * @return string */ private function getFriendlyMessage() { global $mod_strings; switch (get_class($this->throwable)) { case SearchUserFriendlyException::class: return $this->throwable->getMessage(); case SearchInvalidRequestException::class: return $mod_strings['LBL_ELASTIC_SEARCH_SEARCH_INVALID_REQUEST']; case SearchEngineNotFoundException::class: return $mod_strings['LBL_ELASTIC_SEARCH_SEARCH_ENGINE_NOT_FOUND']; case NoNodesAvailableException::class: return $mod_strings['LBL_ELASTIC_SEARCH_NO_NODES_AVAILABLE']; case SearchException::class: return $mod_strings['LBL_ELASTIC_SEARCH_SEARCH']; default: return $mod_strings['LBL_ELASTIC_SEARCH_DEFAULT']; } } /** * Cancels the current output and prints a full screen detailed exception page */ private function printStackTrace() { $whoops = new Run; $handler = new PrettyPageHandler; $handler->addDataTable('SearchQuery', $this->query->jsonSerialize()); $handler->addDataTable('SearchWrapper Status', $this->getSearchWrapperStatus()); $whoops->pushHandler($handler); $whoops->register(); $whoops->handleException($this->throwable); } /** * Returns an array with the SearchWrapper status to be displayed in the detailed view. * * @return array */ private function getSearchWrapperStatus() { try { return [ 'Available Engines' => implode(', ', SearchWrapper::getEngines()), 'Search Controller' => SearchWrapper::getController(), 'Default Search Engine' => SearchWrapper::getDefaultEngine(), 'Friendly Error Message' => $this->getFriendlyMessage(), ]; } catch (\Exception $exception) { return ['error' => 'failed to get SearchWrapper status']; } } /** * Prints the error on the page. */ private function printFriendlyMessage() { global $mod_strings; $message = $this->getFriendlyMessage(); $endMessage = $mod_strings['LBL_ELASTIC_SEARCH_EXCEPTION_END_MESSAGE']; echo '
$message $endMessage
"; } }