ColdFusion 10:使用新的REST API处理和记录错误 [英] ColdFusion 10: Handling and Logging Errors With New 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屋!