Esempio n. 1
0
 public static function printExceptionInfo(\Exception $e)
 {
     if ($e instanceof \CoreApi\Exception || $e instanceof \Flywheel\Exception\Api) {
         self::printError($e->getCode(), $e->getMessage());
     } else {
         if ($app = Base::getApp() && Base::ENV_PRO != Base::getEnv()) {
             \Flywheel\Exception::outputStackTrace($e, 'none');
         }
         self::printError($e->getCode());
     }
 }
Esempio n. 2
0
 /**
  * @param Exception $e
  */
 public static function printExceptionInfo($e)
 {
     while (ob_get_level()) {
         if (!ob_end_clean()) {
             break;
         }
     }
     if (!headers_sent()) {
         $code = $e->getCode();
         if (null == $code) {
             $code = '500';
         }
         if ($e instanceof Exception) {
             $code = '400';
         }
         $headMsg = self::_getHeaderMessage($code);
         header("HTTP/1.1 {$code} {$headMsg}");
     }
     if ($e instanceof \Exception || $e instanceof \Flywheel\Exception\Api) {
         $response = self::_responseError($e);
         $format = \Flywheel\Factory::getRouter()->getFormat();
         switch ($format) {
             case 'xml':
                 header('Content-type:text/xml');
                 break;
             case 'text':
                 break;
             default:
                 header('Content-type:application/json');
                 $response = json_encode($response);
         }
         echo $response;
     } else {
         error_log(self::outputStackTrace($e));
     }
 }