我在我的网站上配置了redmine来处理异常。现在当网站在生产环境中时,我有一个奇怪的例外。
堆栈跟踪:
An exception has been thrown during the rendering of a template ("DateTime::__construct(): Failed to parse time string (date) at position 0 (d): The timezone could not be found in the database") in "ToFrontendBundle:Page:cruise-periodic.html.twig" at line 8.
#95: To\FrontendBundle\Controller\PageController->cruisePreviewAction(8, way, date)
#106: Symfony\Bundle\FrameworkBundle\Controller\Controller->render("ToFrontendBundle:Page:cruise-periodic.html.twig", array)
#112: Symfony\Bundle\TwigBundle\TwigEngine->renderResponse("ToFrontendBundle:Page:cruise-periodic.html.twig", array, NULL)
#83: Symfony\Bundle\TwigBundle\TwigEngine->render("ToFrontendBundle:Page:cruise-periodic.html.twig", array)
#53: Symfony\Bridge\Twig\TwigEngine->render("ToFrontendBundle:Page:cruise-periodic.html.twig", array)
#4423: Twig_Template->render(array)
#4416: Twig_Template->display(array)
#4446: Twig_Template->displayWithErrorHandling(array, array)
但是,我处理的异常如下:
try {
$date = new \DateTime($date);
$date = $date->format('j-n-Y');
} catch (\Exception $e) {
$date = new \DateTime("now");
$date = $date->format('j-n-Y');
$first = false;
}
我的巡航 - periodic.html.twig:
<span class="padding-left-10 light-green text-14 selected-date" data-date="{{ date | date('j/n/Y') }}">{{ date | toDateFormat }}</span>
我做错了什么?
修改 有人导致异常,但我不知道如何。我无法手动测试这种情况。字符串变量“date”和“way”在js中被替换。可能有人找到了dom href并盲目地调用它。可能是机器人还是机器人?我如何阻止他们访问此操作?
答案 0 :(得分:0)
我的意思是尝试执行下一个代码:
try {
$date = new \DateTime('2010-10-10');
$date = $date->format('j-n-Y');
} catch (\Exception $e) {
$date = new \DateTime("now");
$date = $date->format('j-n-Y');
$first = false;
}
它是否也会捕获此异常或它是否有效?