<?php
/*
WAErrorNT.lib, DomCore, the WebAbility(r) Core System
Contains the basic error class to throw when PHP does not support traits (PHP 5.3 and before)
(c) 2008-2017 Philippe Thomassigny
This file is part of DomCore
DomCore is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
DomCore is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DomCore. If not, see <http://www.gnu.org/licenses/>.
*/
/* @UML_Box
|------------------------------------------------------------------|
| WAError: Error base class. |
|------------------------------------------------------------------|
|------------------------------------------------------------------|
|------------------------------------------------------------------|
@End_UML_Box */
namespace core;
class WAError extends \Exception
{
function __construct($message = null)
{
parent::__construct($message);
}
public function __toString()
{
$message = $this->getMessage();
if (WADebug::getHTMLAPI())
{
$error = <<<EOF
<table border="1"><tr><td bgcolor="#fdd"><b>ERROR: </b></td><td bgcolor="#fdd">{$message}</td></tr>
<tr><td><b>THROWN: </b></td><td>{$this->file} (<b>{$this->line}</b>)</td></tr>
<tr><td valign="top"><b>TRACE: </b></td><td valign="top">
EOF;
foreach($this->getTrace() as $k => $t)
{
$error .= (isset($t['file'])?$t['file']:'No file').' (<b>'.(isset($t['line'])?$t['line']:'No line').'</b>) :: calling <font color="blue">'.(isset($t['class'])?$t['class']:'').(isset($t['type'])?$t['type']:'').(isset($t['function'])?$t['function']:'No function').'</font><br />'.PHP_EOL;
}
$error .= '</td></tr>'.PHP_EOL.'</table>';
return $error;
}
$error = "ERROR: {$message}".PHP_EOL."THROWN: {$this->file} ({$this->line})".PHP_EOL."TRACE:".PHP_EOL;
foreach($this->getTrace() as $k => $t)
{
$error .= (isset($t['file'])?$t['file']:'No file').' ('.(isset($t['line'])?$t['line']:'No line').') :: calling '.(isset($t['class'])?$t['class']:'').(isset($t['type'])?$t['type']:'').(isset($t['function'])?$t['function']:'No function').PHP_EOL;
}
return $error;
}
}
?>
|