Fatal error: Uncaught exception too long
I'm using throw new Exception(...)
to handle errors, but these errors are huge! With 7 stack traces I get a 5 line error.
Let's say I call for a property that doesn't exist. I want to simp开发者_如何学JAVAly display the property X doesn't exist
message, and the location where it was called: in file.php, line Y
Is that possible?
I assume you simply want this for your own personal debugging. You could do a few things:
a) Learn how to read the exception errors
b) Create an exception handler and only output a few things:
set_exception_handler(function(Exception $e)
{
echo $e->getMessage();
// echo out whatever you want to see
die();
});
Reference the docs to see what information is available.
c) Use an extension like xdebug that already provides a pretty exception handler
Use trigger_error and set_error_handler , and you'll be able to know LINE and FILE (in handler function).
Also, in handler you can call debug_backtrace and read all information that you need.
精彩评论