我可以在vbscript中抛出错误吗? [英] Can I throw an error in vbscript?
本文介绍了我可以在vbscript中抛出错误吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Err
全局变量读过VBscript的错误处理。 然而,有没有办法可以产生自己的错误?例如,如果我的一个函数传递错误的参数类型,我宁愿我的脚本在这一点上失败,然后尝试继续。
解决方案
是的,你可以。使用 Err.Raise
方法,例如:
Err.Raise 5'无效的过程调用或参数
有关VBScript标准错误代码的列表,请参阅错误(VBScript)。
I'm used to programing in C#, which obviously has some pretty robust error handling. Now I'm working on a short project in VBScript. I've read about the error handling with VBscript using "On Error _______" and the Err
global variable.
However, is there some way I can generate my own errors? For example if one of my functions is passed the wrong type of parameter I'd rather my script just flat out fail at that point then try to continue.
解决方案
Yes, you can. Use the Err.Raise
method, e.g.:
Err.Raise 5 ' Invalid procedure call or argument
For a list of VBScript's standard error codes, see Errors (VBScript).
这篇关于我可以在vbscript中抛出错误吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文