Get the exception message for an exception.

@param  \Exception  $e
@return string
504612
protected function getMessage($e)
    {
        $path = last($this->lastCompiled);

        return $e->getMessage() .' (View: ' .realpath($path) .')';
    }
924168
public function writeException(\Exception $e)
    {
        if ($this->verboseException) {
            $text = sprintf("[%s]\n%s\nIn %s at line %s\n%s", 
                get_class($e),
                $e->getMessage(),
                $e->getFile(),
                $e->getLine(),
                $e->getTraceAsString()
            );
        } else {
            $text = sprintf("\n[%s]\n%s\n", get_class($e), $e->getMessage());
        }

        $box = new Widgets\Box($this->textWriter, $text, '');
        $out = Colors::colorizeLines($box, Colors::WHITE, Colors::RED);
        $out = TextFormater::apply($out, array('indent' => 2));
        $this->textWriter->writeln($out);
        return $this;
    }
1120613
protected function formatExceptionError(Exception $e, $fallbackMessage = null)
    {
        if (    (config('app.debug') || $this->core->config('debug'))
            &&  $this->core->apiConfig('debug.local-exception-trace', true)
        ) {
            return $this->formatExceptionErrorForLocal($e, $fallbackMessage);
        }

        $message = $e->getMessage() ?: $fallbackMessage;

        return [
            'message' => $message,
        ];
    }
1237517
protected function handleError(\Exception $e) {
		$kernel = $this->getDefaultKernel();
		$application = $this->getDefaultApplication($kernel);

		$kernel->getResponse()->addValue("error", $e->getMessage());
		$this->logger->logError($e->getMessage());

		return $application;
	}
806745
protected function handleException(\Exception $e)
    {
        $data = [];

        if ($this->controller->app->get('system.debug')) {
            $data['exception'] = get_class($e);
            $data['backtrace'] = BacktraceHelper::normalizeBacktraces($e->getTrace());

            foreach ($data['backtrace'] as &$datum) {
                unset($datum['pathname']);
            }

            if (class_exists(DebuggerHelper::class)) {
                try {
                    $data['debug_messages'] = (array) DebuggerHelper::getInstance()->get('debug.messages');
                } catch (\Exception $e) {
                    // None
                }
            }
        }

        $this->controller->setResponse(
            $this->controller
                ->getResponse()
                ->withStatus(
                    ErrorManager::normalizeCode($e->getCode()),
                    ErrorManager::normalizeMessage($e->getMessage())
                )
        );

        $message = !WINDWALKER_DEBUG ? $e->getMessage() : sprintf(
            '#%d %s - File: %s (%d)',
            $e->getCode(),
            $e->getMessage(),
            $e->getFile(),
            $e->getLine()
        );

        return new JsonBuffer($message, $data, false, $e->getCode());
    }
479349
public function formatException(\Exception $e) {
        $xml = new XMLWriter();
        $xml->openMemory();
        $xml->writeElement('class', get_class($e));
        $xml->writeElement('message', htmlspecialchars($e->getMessage(), ENT_QUOTES, 'UTF-8'));
        $xml->writeElement('file', htmlspecialchars($e->getFile(), ENT_QUOTES, 'UTF-8'));
        $xml->writeElement('line', $e->getLine());
        $xml->writeElement('trace', htmlspecialchars($e->getTraceAsString(), ENT_QUOTES, 'UTF-8'));

        return $xml->outputMemory();
    }
817662
protected function getExceptionMessage(): string
    {
        $exception = $this->getException();

        if ($exception instanceof UserException) {
            return $exception->getMessage();
        }

        return $this->getDefaultMessage();
    }
980831
public static String getExceptionMessage(Exception e) {
        if (e.getCause() != null && e.getCause().getMessage() != null) {
            String s = getscard(e.getCause().getMessage());
            if (s != null)
                return s;
        }
        if (e.getMessage() != null) {
            String s = getscard(e.getMessage());
            if (s != null)
                return s;
        }
        return e.getMessage();
    }
389014
public static function convertExceptionToString($exception)
    {
        if ($exception instanceof \Exception) {
            $message = "Exception ({$exception->getTraceAsString()})";
        } elseif ($exception instanceof \ErrorException) {
            $message = "{$exception->getTraceAsString()}";
        } else {
            $message = 'Exception';
        }
        $message .= " '".get_class($exception)."' with message '{$exception->getMessage()}' \n\nin "
            .$exception->getFile().':'.$exception->getLine()."\n\n"
            ."Stack trace:\n".$exception->getTraceAsString();

        return $message;
    }
589842
protected function getCode(\Exception $exception)
    {
        return $exception instanceof \ErrorException ?
            $this->getHumanErrorCode($exception->getSeverity()) :
            $exception->getCode()
        ;
    }
52461
protected function getErrorResponse(Exception $e)
    {
        switch (get_class($e)) {
            case ForbiddenException::class:
                $response = $this->forbidden(
                    new ErrorBag([new Error('Forbidden', $e->getMessage())])
                );
                break;
            default:
                $response = $this->errorResponse(
                    new ErrorBag([new Error('Bad Request', 'Request could not be served.')])
                );
        }

        return $response;
    }
1332941
public function handleException($e)
    {
        if ($e instanceof Action) {
            return $this->error(Code::NOT_FOUND);
        }

        return $this->error($e->getCode(), $e->getMessage());
    }
476847
private function getExceptionMessage(\Exception $ex)
    {
        if ($ex instanceof RequestException && $ex->hasResponse()) {
            return (string) $ex->getResponse()->getBody();

            try {
                $this->jsonDecode($res);
                return $res;
            } catch (\InvalidArgumentException $e) {
                // no-op
            }
        }

        return $ex->getMessage();
    }
867985
protected function prepareException(Exception $e)
    {
        $e = parent::prepareException($e);

        if ($e instanceof MethodNotAllowedHttpException) {
            $e = new HttpException(405, 'Method not allowed', $e->getPrevious(), $e->getHeaders(), $e->getCode());
        }

        return $e;
    }
1167634
public static function exceptionHandler(\Exception $e)
    {
//echo __METHOD__;
        $error = Error::createFromException($e, Response::STATUS_ERROR);
        $status = method_exists($e, 'getStatus') ? $e->getStatus() : Response::STATUS_ERROR;
        Container::get('response')
            ->setStatus($status);
        Container::get('controller')
            ->addError($error)
            ->serve();
    }
225836
public function formatException(\Exception $e) {
        $entry = array();

        $entry['class'] = get_class($e);
        $entry['message'] = $e->getMessage();
        $entry['file'] = $e->getFile();
        $entry['line'] = $e->getLine();
        $entry['trace'] = $e->getTraceAsString();

        return $entry;
    }
875600
protected function convertDatabaseException(\Exception $e)
	{
		if($e instanceof DatabaseException)
		{
			return $e;
		}
		
		// Check for PDO exception in order to determine FK violation:
		$cause = $e;
		
		if(!$cause instanceof \PDOException)
		{
			while(NULL !== ($cause = $cause->getPrevious()))
			{
				if($cause instanceof \PDOException)
				{
					break;
				}
			}
		}
		
		if($cause instanceof \PDOException)
		{
			switch($this->driverName)
			{
				case DB::DRIVER_MYSQL:
					return $this->convertMySqlException($cause, $e);
				case DB::DRIVER_POSTGRESQL:
					return $this->convertPostgresException($cause, $e);
				case DB::DRIVER_SQLITE:
					return $this->convertSqliteException($cause, $e);
			}
		}
		
		return new DatabaseException($e->getMessage(), 0, $e);
	}