Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I throw an error in 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.

like image 878
Eric Anastas Avatar asked Dec 21 '10 19:12

Eric Anastas


People also ask

Which of the following is used to throw an error in VBScript?

Q 42 - Which of the following is used to clear error in VBScript? A - Err.

How do you catch errors in VBScript?

The Err object is part of the VBScript language and contains information about the last error to occur. By checking the properties of the Err object after a particular piece of code has executed, you can determine whether an error has occurred and, if so, which one.

How many types of errors are there in VBScript?

VB.NET Masterclass: Learn Visual Basic and VBScript There are three types of errors in programming: (a) Syntax Errors, (b) Runtime Errors, and (c) Logical Errors.

What is error object in VBScript?

The Err object is an intrinsic object with global scope — there is no need to create an instance of it in your code. The properties of the Err object are set by the generator of an error — Visual Basic, an Automation object, or the VBScript programmer. The default property of the Err object is Number. Err.


1 Answers

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).

like image 130
Helen Avatar answered Oct 13 '22 06:10

Helen