Example #1
0
 /**
  * All exceptions are piped through this method from the framework workflow. This method will mask
  * any foreign exceptions with a "scent" of the native application's exception, so it can render
  * correctly when displayed on the error page.
  * @param Exception $proposedException The exception candidate that has been thrown.
  * @return mixed Error page contents
  */
 public function handleException(Exception $proposedException)
 {
     // Disable the error handler for test and CLI environment
     if (App::runningUnitTests() || App::runningInConsole()) {
         return;
     }
     // Detect AJAX request and use error 500
     if (Request::ajax()) {
         return $proposedException instanceof AjaxException ? $proposedException->getContents() : static::getDetailedMessage($proposedException);
     }
     $this->beforeHandleError($proposedException);
     // Clear the output buffer
     while (ob_get_level()) {
         ob_end_clean();
     }
     // Friendly error pages are used
     if (($customError = $this->handleCustomError()) !== null) {
         return $customError;
     }
     // If the exception is already our brand, use it.
     if ($proposedException instanceof BaseException) {
         $exception = $proposedException;
     } elseif (static::$activeMask !== null) {
         $exception = static::$activeMask;
         $exception->setMask($proposedException);
     } else {
         $exception = new ApplicationException($proposedException->getMessage(), 0);
         $exception->setMask($proposedException);
     }
     return $this->handleDetailedError($exception);
 }
 /**
  * Masks this exception with the details of the supplied. The error code for
  * this exception object will determine how the supplied exception is used.
  * Error 100: A general exception. Inherits \System\Classes\ExceptionBase::applyMask()
  * Error 200: Mask the exception as INI content.
  * Error 300: Mask the exception as PHP content.
  * Error 400: Mask the exception as Twig content.
  * @param \Exception $exception The exception to modify.
  * @return void
  */
 public function applyMask(Exception $exception)
 {
     if ($this->code == 100 || $this->processCompoundObject($exception) === false) {
         parent::applyMask($exception);
         return;
     }
 }
Example #3
0
 /**
  * Softens a detailed authentication error with a more vague message when
  * the application is not in debug mode. This is for security reasons.
  */
 public function __construct($message = "", $code = 0, Exception $previous = null)
 {
     $this->softErrors = !Config::get('app.debug', false);
     if ($this->softErrors) {
         $message = $this->errorMessage;
     }
     parent::__construct($message, $code, $previous);
 }