Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
xdebug exception fatal
<?php
ini_set("display_errors", 1);
ini_set("error_reporting", E_ALL);
echo "<pre>";
class MyException extends Exception {
function __construct($message) {
parent::__construct($message);
$this->line = "42"; // this triggers it. if it's before the constructor, PHP freaks out regardless of xdebug
}
}
try {
throw new MyException();
} catch (Exception $ex) {
var_dump ($ex);
}
echo "survived";
/*
without xdebug:
object(MyException)#93 (7) {
["message":protected]=>
string(3) "BLA"
["string":"Exception":private]=>
string(0) ""
["code":protected]=>
int(0)
["file":protected]=>
string(61) "/www/deviantart.lan/xdebugexception.php"
["line":protected]=>
string(2) "42"
["trace":"Exception":private]=>
array(0) {
}
["previous":"Exception":private]=>
NULL
}
survived
with xdebug:
( ! ) Fatal error: Your exception class uses incorrect types for common properties: 'message' and 'file' need to be a string and 'line' needs to be an integer. in /www/deviantart.lan/xdebugexception.php on line 17
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.