IIS 7.5,2008rc2,经典asp,500错误消息:
由于发生内部服务器错误,无法显示页面.
我需要知道如何配置IIS以获得更详细的错误.
我已经尝试在ASP配置中设置为true所有调试选项.
但那没用.谁能帮我?
我正在尝试部署ASP.NET应用程序.我已将该站点部署到IIS,但在使用浏览器访问它时,它显示了以下内容:
服务器错误
500内部服务器错误.
您正在查找的资源存在问题,无法显示.
在摆弄web.config之后,我得到了:
由于发生内部服务器错误,无法显示页面.
如何查看此服务器错误背后的实际问题?
我正在使用Swift 3语法定义自定义错误类型,我想提供一个用户友好的错误描述,该描述由对象的localizedDescription属性返回Error.我该怎么做?
public enum MyError: Error {
case customError
var localizedDescription: String {
switch self {
case .customError:
return NSLocalizedString("A user-friendly description of the error.", comment: "My error")
}
}
}
let error: Error = MyError.customError
error.localizedDescription
// "The operation couldn’t be completed. (MyError error 0.)"
Run Code Online (Sandbox Code Playgroud)
有没有办法让localizedDescription我返回我的自定义错误描述("用户友好的错误描述.")?请注意,此处的错误对象是类型Error而不是MyError.当然,我可以将对象强制转换为MyError
(error as? MyError)?.localizedDescription
Run Code Online (Sandbox Code Playgroud)
但是有没有办法让它工作而不会转换为我的错误类型?
我正在为客户开发API服务层,并且我被要求在全局范围内捕获并记录所有错误.
因此,虽然通过使用ELMAH或通过向以下内容添加类似内容,可以轻松处理类似未知端点(或操作)的内容Global.asax:
protected void Application_Error()
{
Exception unhandledException = Server.GetLastError();
//do more stuff
}
Run Code Online (Sandbox Code Playgroud)
...不会记录与路由无关的未处理错误.例如:
public class ReportController : ApiController
{
public int test()
{
var foo = Convert.ToInt32("a");//Will throw error but isn't logged!!
return foo;
}
}
Run Code Online (Sandbox Code Playgroud)
我还尝试[HandleError]通过注册此过滤器来全局设置该属性:
filters.Add(new HandleErrorAttribute());
Run Code Online (Sandbox Code Playgroud)
但这也不会记录所有错误.
如何拦截错误,例如通过调用/test上面生成的错误,以便我可以记录它们?似乎这个答案应该是显而易见的,但我已经尝试了迄今为止我能想到的一切.
理想情况下,我想在错误记录中添加一些内容,例如请求用户的IP地址,日期,时间等.我还希望能够在遇到错误时自动通过电子邮件发送支持人员.所有这些我都可以做到,只要我能在它们发生时拦截这些错误!
感谢Darin Dimitrov,我接受了他的回答,我弄清楚了. 的WebAPI并没有以同样的方式作为一个普通MVC控制器处理错误.
这是有效的:
1)在命名空间中添加自定义过滤器:
public class ExceptionHandlingAttribute : ExceptionFilterAttribute
{
public override void OnException(HttpActionExecutedContext context)
{
if (context.Exception is BusinessException)
{
throw new HttpResponseException(new …Run Code Online (Sandbox Code Playgroud) 这是一个FAQ问题,所以请尽可能完整.答案是社区答案,如果您认为缺少某些内容,请随时编辑.
我正在使用R并尝试some.function但我收到以下错误消息:
Error: could not find function "some.function"
Run Code Online (Sandbox Code Playgroud)
这个问题经常出现.当你在R中遇到这种类型的错误时,你怎么解决它?
我正在使用python脚本作为流体动力学代码的驱动程序.当运行模拟时,我subprocess.Popen用来运行代码,从stdout和stderr收集输出到subprocess.PIPE---然后我可以打印(并保存到日志文件)输出信息,并检查是否有任何错误.问题是,我不知道代码是如何进展的.如果我直接从命令行运行它,它会给我输出关于它在什么时间迭代,什么时间,下一个时间步骤是什么等等的输出.
有没有办法既存储输出(用于记录和错误检查),还产生实时流输出?
我的代码的相关部分:
ret_val = subprocess.Popen( run_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True )
output, errors = ret_val.communicate()
log_file.write(output)
print output
if( ret_val.returncode ):
print "RUN failed\n\n%s\n\n" % (errors)
success = False
if( errors ): log_file.write("\n\n%s\n\n" % errors)
Run Code Online (Sandbox Code Playgroud)
最初我正在run_command通过管道,tee以便副本直接进入日志文件,并且流仍然直接输出到终端 - 但这样我就不能存储任何错误(对我的知识).
编辑:
临时解决方案:
ret_val = subprocess.Popen( run_command, stdout=log_file, stderr=subprocess.PIPE, shell=True )
while not ret_val.poll():
log_file.flush()
Run Code Online (Sandbox Code Playgroud)
然后,在另一个终端,运行tail -f log.txt(st log_file = 'log.txt').
在Swift 2.0中,Apple引入了一种处理错误的新方法(do-try-catch).几天前在Beta 6中引入了更新的关键字(try?).另外,知道我可以使用try!.3个关键字之间有什么区别,何时使用?
我正在处理如何在Python中引发警告而不必让程序崩溃/停止/中断的问题.
我使用以下简单函数,只检查用户是否传递了非零数字.如果用户传递零,程序应警告用户,但继续正常.它应该像下面的代码一样工作,但应该使用类Warning(),Error()或Exception()而不是手动打印警告.
def is_zero(i):
if i != 0:
print "OK"
else:
print "WARNING: the input is 0!"
return i
Run Code Online (Sandbox Code Playgroud)
如果我使用下面的代码并将0传递给函数,程序将崩溃并且永远不会返回值.相反,我希望程序正常继续,只是通知用户他将0传递给该函数.
def is_zero(i):
if i != 0:
print "OK"
else:
raise Warning("the input is 0!")
return i
Run Code Online (Sandbox Code Playgroud)
我希望能够测试是否已经通过unittest对其进行了测试.如果我只是打印出来的消息,我就无法在unittest中使用assertRaises来测试它.
我有一个使用C#在VS2010中编写的Windows窗体应用程序,并在app.config文件中获得以下错误:
Message 4 Could not find schema information for the attribute 'name'
Message 8 Could not find schema information for the attribute 'name'
Message 12 Could not find schema information for the attribute 'name'
Message 5 Could not find schema information for the attribute 'serializeAs'
Message 15 Could not find schema information for the element 'CCP_Utility.Settings1'
Message 2 Could not find schema information for the element 'CCP_Utility.Properties.Settings'
Message 3 Could not find schema information for the element 'setting' …Run Code Online (Sandbox Code Playgroud) 我使用转换我的代码Handler来AsyncTask.后者非常擅长它 - 在主UI线程中异步更新和处理结果.我不清楚的是,如果出现问题,如何处理异常AsyncTask#doInBackground.
我这样做的方法是有一个错误处理程序并向它发送消息.它工作正常,但它是"正确的"方法还是有更好的选择?
另外我理解如果我将错误处理程序定义为Activity字段,它应该在UI线程中执行.但是,有时(非常不可预测)我会得到一个异常,说触发的代码Handler#handleMessage是在错误的线程上执行的.我应该初始化错误处理程序Activity#onCreate吗?放置runOnUiThread到Handler#handleMessage似乎是多余的,但执行非常可靠.