Components.returnCode 编辑
Components.returnCode
is a property which can hold an XPCOM return code additionally to the value returned by the return
statement.
Note that Components.returnCode
is currently non-functional due to bug 287107. This problem was introduced in Mozilla 1.4.
Usage
Components.returnCode
is a property that can be used to indicate to an XPCOM caller of the JavaScript method that the method is returning a specific nsresult
code.
Generally, XPConnect does a fine job of making it unnecessary for JavaScript code to worry about nsresult
codes. By default the successful completion of the JavaScript method will cause XPConnect to return a result code of NS_OK
to the caller. If the JavaScript code needs to signal failure then that is done by throwing an exception. However, there are a very few XPCOM interfaces that specify success code return values. Components.returnCode
exists in order to make it possible to implement these rare interfaces in JavaScript.
Example
var foo = { bar: function(i) { if (yada_yada) Components.returnCode = 5; return i * 2; } };
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论