Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Magento How To Show Full Error/Exception Message Instead of Truncated One
<?php
function getExceptionTraceAsString($exception) {
$rtn = "";
$count = 0;
foreach ($exception->getTrace() as $frame) {
$args = "";
if (isset($frame['args'])) {
$args = array();
foreach ($frame['args'] as $arg) {
if (is_string($arg)) {
$args[] = "'" . $arg . "'";
} elseif (is_array($arg)) {
$args[] = "Array";
} elseif (is_null($arg)) {
$args[] = 'NULL';
} elseif (is_bool($arg)) {
$args[] = ($arg) ? "true" : "false";
} elseif (is_object($arg)) {
$args[] = get_class($arg);
} elseif (is_resource($arg)) {
$args[] = get_resource_type($arg);
} else {
$args[] = $arg;
}
}
$args = join(", ", $args);
}
$rtn .= sprintf( "#%s %s(%s): %s(%s)\n",
$count,
isset($frame['file']) ? $frame['file'] : 'unknown file',
isset($frame['line']) ? $frame['line'] : 'unknown line',
(isset($frame['class'])) ? $frame['class'].$frame['type'].$frame['function'] : $frame['function'],
$args );
$count++;
}
return $rtn;
}
@arosenhagen

This comment has been minimized.

Copy link
Owner Author

@arosenhagen arosenhagen commented Dec 30, 2014

add getExceptionTraceAsString to app/code/core/Mage/Core/functions.php
in app/Mage.php function printException substitute
print $e->getTraceAsString();
with
print getExceptionTraceAsString($e);
and
self::log("\n" . $e->__toString(), Zend_Log::ERR, $file);
with
self::log("\n" . $e->getMessage() . getExceptionTraceAsString($e), Zend_Log::ERR, $file);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment