s9y/Serendipity — comment on commit 7e0cdf30afcbd2c33ffb5ded8580137d672140bf
File:  line 0
By ophian:

What a question, Garvin.... It took some time for me ;-)

The answer is Yes and No.
When doing it the first way, it does not get overwritten (play arround with ini_set display_errors and const), while the second is!
I think it is because of this:
throw new Exception('Exception by direct-use - like in 2cd example - extends from diplay_error setting');

if this is true, how shall we implement it.... (maybe to use everywhere)?

message = $message;
$this->code = $code;
$this->severity = $severity;
$this->file = $filename;
$this->line = $lineno;
}

public function getSeverity() {
return $this->severity;
}
}

function exception_error_handler($errno, $errstr, $errfile, $errline ) {
throw new SerendipityErrorHandler($errstr, 0, $errno, $errfile, $errline);
}

set_error_handler("exception_error_handler", E_ALL);

function A() {
$foo->bar; // Purposely cause error
}

function B($c) {
A();
}

try {
B('foobar');
} catch (Exception $e) {
if (true === DEBUG)
{
// Debugsserver
echo '

Exception on Debugsserver!: ';print_r($e->getTrace());echo '

';
}
else
{
// Liveserver
echo 'Exception on Livesserver!: '.$e->getTraceAsString();
}
#var_dump($e->getTrace());
}

echo "
\n---
\n";

///////////////////////////////////////////////////////
// Second, which !is! overriden by display_errors off
///////////////////////////////////////////////////////

function getSquareRoot($val)
{
if (!is_numeric($val))
{
throw new Exception('Eine Zahl du Nase!');
}
else
{
return (bcsqrt ($val, 2));
}
}

try
{
echo getSquareRoot(5);
echo getSquareRoot('bla');
}
catch (Exception $e)
{
if (true === DEBUG)
{
// Debugsserver
throw new Exception('Exception on Debugsserver!');
}
else
{
// Liveserver
throw new Exception('Exception on Livesserver!');
}
}
?>