ThrowError Property  

Enable or disable error handling by the container of the control.


object.ThrowError = { True | False }


Error handling for methods can be done in either of two different styles, according to the value of this property.

If the ThrowError property is set to False, the application should check the return value of any method that is used, and report errors based upon the documented value of the return code. It is the responsibility of the application to interpret the error code, if it is desired to explain the error in addition to reporting it.

If the ThrowError property is set to True, then errors occurring within the control will be thrown to the container of the control. In addition, the OnError event will fire. For example, in Visual Basic, it is recommended that the OnError mechanism be used to catch errors.

Note that if an error occurs while a property value is being accessed, an error will be raised regardless of the value of the ThrowError property, but the OnError event will not be fired.

Data Type



The following example handles errors by checking the return code of a method:

HttpClient1.ThrowError = False
nError = HttpClient1.Connect(strHostName)

If nError > 0 Then
    MsgBox HttpClient1.LastErrorString, vbExclamation
    Exit Sub

The following example handles errors by throwing them to the container:

On Error Resume Next: Err.Clear

HttpClient1.ThrowError = True
HttpClient1.Connect strHostName

If Err.Number <> 0
    MsgBox Err.Description, vbExclamation
    Exit Sub
On Error GoTo 0

See Also

LastError Property, LastErrorString Property, OnError Event