How to Have a Detailed Trace of a Slim Application Error

夙愿已清 提交于 2020-01-17 05:37:30

问题


I have 10000 lines of code outlining routes of my API implemented using the Slim Framework. However, I got an error message preg_match(): Compilation failed: two named subpatterns have the same name at offset 89. The problem is, I got the stack trace referring to this statement preg_match('/cost-centers...', '/overview/funds...', NULL) at the Slim Route.php. Now that my URLs are lengthy, I can't pinpoint which of the URLs have the same name.

Is there any way to have a more detailed stack trace instead of displaying these shortened format?


回答1:


Thanks to mgansler for this tip.

I just used a custom error handler with PHP Exception::getTrace() function. I also turned the Slim's default debugging off to ensure that the custom error handler is invoked.

Code goes like this:

$app = new \Slim\Slim(array(
    'debug' => false
));
$app->error(function (\Exception $e) use ($app) {
    //enter manipulation of $e->getTrace()
    //or just var_dump($e->getTrace()) but the format would be chaotic
});


来源:https://stackoverflow.com/questions/32452479/how-to-have-a-detailed-trace-of-a-slim-application-error

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!