public static function exceptionAsString(\Exception $exception) { $content = '<div style="font-family:calibri,arial; font-size:14px;">'; $content .= '<h1>An uncaught exception was thrown</h1>'; $content .= '<h2 style="color:#B20000;">(' . $exception->getCode() . ') '; $content .= $exception->getMessage() . '</h2>'; //If we have a cubex exception, lets provide some debug data if ($exception instanceof CubexException && $exception->getDebug() !== null) { $content .= '<h3 style="color:#B20000;">Cubex Debug Data</h3>'; $content .= '<div style="padding:10px;background:#E1E9F5; '; $content .= 'border:1px solid #333333;">'; $debug = $exception->getDebug(); if (is_string($debug)) { $debug = trim($debug); $content .= nl2br($debug); } else { if (is_array($debug) || is_object($debug)) { $content .= '<pre>'; $content .= print_r($debug, true); $content .= '</pre>'; } else { $content .= '<pre>'; ob_start(); var_dump($debug); $content .= ob_get_clean(); $content .= '</pre>'; } } $content .= '</div>'; $content .= '<hr/>'; $content .= '<h3>Stack Trace</h3>'; } $content .= '<div style="padding:10px;background:#FAF7E7;'; $content .= 'border:1px solid #333333;line-height: 25px;">'; $content .= nl2br($exception->getTraceAsString()) . '</div>'; $content .= '</div>'; return $content; }