public static function decodeException($exception) { $message =
$exception->
getMessage();
$backtrace =
$exception->
getTrace();
// Add the line throwing the exception to the backtrace.
array_unshift($backtrace,
['line' =>
$exception->
getLine(), 'file' =>
$exception->
getFile()]);
// For PDOException errors, we try to return the initial caller,
// skipping internal functions of the database layer.
if ($exception instanceof \PDOException ||
$exception instanceof DatabaseExceptionWrapper
) { $driver_namespace = Database::
getConnectionInfo()['default'
]['namespace'
];
$backtrace = Connection::
removeDatabaseEntriesFromDebugBacktrace($backtrace,
$driver_namespace);
if (isset($exception->query_string,
$exception->args
)) { $message .= ": " .
$exception->query_string . "; " .
print_r($exception->args, TRUE
);
} } $caller =
static::
getLastCaller($backtrace);
return [ '%type' =>
get_class($exception),
// The standard PHP exception handler considers that the exception message
// is plain-text. We mimic this behavior here.