ThrowError Property  
 

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

Syntax

object.ThrowError = { True | False }

Remarks

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

Boolean

Example

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

FileEncoder1.ThrowError = False
nError = FileEncoder1.EncodeFile(strInputFile, strOutputFile)

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

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

On Error Resume Next: Err.Clear

FileEncoder1.ThrowError = True
FileEncoder1.EncodeFile strInputFile, strOutputFile

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

See Also

LastError Property, LastErrorString Property, OnError Event