如何在 Symfony 1.4 中模拟错误 500? [英] How to simulate an error 500 in Symfony 1.4?

查看:23
本文介绍了如何在 Symfony 1.4 中模拟错误 500?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 web/errors/ 中创建了一个 error500.php 文件,现在想测试它.

I created an error500.php file in web/errors/ and would now like to test it.

我试图将这一行放在我的一个操作中:

I tried to put this line in one of my actions:

$this->getResponse()->setStatusCode(500);

不幸的是,它似乎被忽略了.

Unfortunately it looks like it's ignored.

你们知道这里发生了什么吗?

Do you guys have any idea of what's happening here?

我使用的是 Symfony 1.4.

I'm using Symfony 1.4.

Firebug 告诉我该错误实际上已触发,但此后页面仍在加载.我在生产环境中.

Firebug is telling me that the error is actually fired but the page is still loading afterwards. And I'm in the prod env.

推荐答案

我很确定抛出任何异常都会触发错误页面:

I'm pretty sure throwing any exception should trigger the error page:

throw new sfException('Testing the 500 error');

然而,symfony 1.2+中错误页面的位置是不同的:

However, the location of the error page is different in symfony 1.2+:

config/error/error.html.php

将您的 web/errors/error500.php 文件移动到这个位置.

move your web/errors/error500.php file to this location instead.

这篇关于如何在 Symfony 1.4 中模拟错误 500?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆