| 1 |
<?php |
| 2 |
/*! |
| 3 |
* Hybridauth |
| 4 |
* https://hybridauth.github.io | https://github.com/hybridauth/hybridauth |
| 5 |
* (c) 2017 Hybridauth authors | https://hybridauth.github.io/license.html |
| 6 |
*/ |
| 7 |
|
| 8 |
namespace Hybridauth\Exception; |
| 9 |
|
| 10 |
/** |
| 11 |
* Hybridauth Base Exception |
| 12 |
*/ |
| 13 |
class Exception extends \Exception implements ExceptionInterface |
| 14 |
{ |
| 15 |
/** |
| 16 |
* Shamelessly Borrowed from Slimframework |
| 17 |
* |
| 18 |
* @param $object |
| 19 |
*/ |
| 20 |
public function debug($object) |
| 21 |
{ |
| 22 |
$title = 'Hybridauth Exception'; |
| 23 |
$code = $this->getCode(); |
| 24 |
$message = $this->getMessage(); |
| 25 |
$file = $this->getFile(); |
| 26 |
$line = $this->getLine(); |
| 27 |
$trace = $this->getTraceAsString(); |
| 28 |
|
| 29 |
$html = sprintf('<h1>%s</h1>', $title); |
| 30 |
$html .= '<p>Hybridauth has encountered the following error:</p>'; |
| 31 |
$html .= '<h2>Details</h2>'; |
| 32 |
|
| 33 |
$html .= sprintf('<div><strong>Exception:</strong> %s</div>', get_class($this)); |
| 34 |
|
| 35 |
$html .= sprintf('<div><strong>Message:</strong> <font color="#cc0000">%s</font></div>', $message); |
| 36 |
|
| 37 |
$html .= sprintf('<div><strong>File:</strong> %s</div>', $file); |
| 38 |
|
| 39 |
$html .= sprintf('<div><strong>Line:</strong> %s</div>', $line); |
| 40 |
|
| 41 |
$html .= sprintf('<div><strong>Code:</strong> %s</div>', $code); |
| 42 |
|
| 43 |
$html .= '<h2>Trace</h2>'; |
| 44 |
$html .= sprintf('<pre>%s</pre>', $trace); |
| 45 |
|
| 46 |
if ($object) { |
| 47 |
$html .= '<h2>Debug</h2>'; |
| 48 |
|
| 49 |
$obj_dump = print_r($object, true); |
| 50 |
|
| 51 |
// phpcs:ignore |
| 52 |
$html .= sprintf('<b>' . get_class($object) . '</b> extends <b>' . get_parent_class($object) . '</b><pre>%s</pre>', $obj_dump); |
| 53 |
} |
| 54 |
|
| 55 |
$html .= '<h2>Session</h2>'; |
| 56 |
|
| 57 |
$session_dump = print_r($_SESSION, true); |
| 58 |
|
| 59 |
$html .= sprintf('<pre>%s</pre>', $session_dump); |
| 60 |
|
| 61 |
// phpcs:ignore |
| 62 |
echo sprintf("<html><head><title>%s</title><style>body{margin:0;padding:30px;font:12px/1.5 Helvetica,Arial,Verdana,sans-serif;}h1{margin:0;font-size:48px;font-weight:normal;line-height:48px;}strong{display:inline-block;width:75px;}</style></head><body>%s</body></html>", $title, $html); |
| 63 |
} |
| 64 |
} |
| 65 |
|