ColdFusion 10:使用新的 REST API 处理和记录错误 [英] ColdFusion 10: Handling and Logging Errors With New REST API

查看:15
本文介绍了ColdFusion 10:使用新的 REST API 处理和记录错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 ColdFusion 10 的新 REST API:http://www.adobe.com/devnet/coldfusion/articles/restful-web-services.html

I'm using ColdFusion 10's new REST API: http://www.adobe.com/devnet/coldfusion/articles/restful-web-services.html

每当出现异常时,API 都会很好地处理它并自动返回如下内容:

Whenever there's an exception, the API handles it nicely and automatically returns something like this:

HTTP/1.1 500 Internal Server Error
Content-Length: 52
Content-Type: application/json
Date: Fri, 22 Feb 2013 01:07:49 GMT

{"Message":"Element FOO is undefined in ARGUMENTS."}

问题是以下都没有被调用:

The problem is that neither of the following gets called:

  • 站点范围的错误处理程序
  • Application.cfc 的 onError

似乎 REST API 处理了错误并且异常没有冒泡.每当发生服务器端错误时,我都喜欢给自己发送一封电子邮件(带有错误详细信息).关于如何使用新的 REST API 有什么想法吗?

It seems like the REST API handles the error and the exception doesn't bubble up. I like to send myself an email (with error details) whenever server-side errors occur. Any thoughts on how I can do with the new REST API?

推荐答案

这并不理想,但您可以在每个方法中添加一个 try/catch,在出错时向您发送电子邮件,然后重新抛出.

It's not ideal, but you could add a try / catch in each method that sends you an email on error then rethrows.

这篇关于ColdFusion 10:使用新的 REST API 处理和记录错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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