Example #1
0
 /**
  * Handle an exception from the ApiBeforeMain hook.
  *
  * This tries to print the exception as an API response, to be more
  * friendly to clients. If it fails, it will rethrow the exception.
  *
  * @since 1.23
  * @param Exception $e
  * @throws Exception
  */
 public static function handleApiBeforeMainException(Exception $e)
 {
     ob_start();
     try {
         $main = new self(RequestContext::getMain(), false);
         $main->handleException($e);
     } catch (Exception $e2) {
         // Nope, even that didn't work. Punt.
         throw $e;
     }
     // Log the request and reset cache headers
     $main->logRequest(0);
     $main->sendCacheHeaders(true);
     ob_end_flush();
 }