Error Handling

Errors that may occur within the class or core API are provided to your application as exceptions. This means that as you use the device, you do not need to check return values for error codes. Instead, if an error occurs, an exception will be raised and the applicable error handling code you have designated (if any) will be executed. As a rule, you should include error handling code for your application so that, for example, if an attempt to connect to the device fails, it does not cause an unhandled exception (which causes the application to exit).

The exception class used in .NET languages is Eth32Exception. This class inherits from the System.Exception class and adds the ErrorCode member. The ErrorCode member contains one of the possible values of the EthError enumerator, indicating more specifically what caused the error. The following example in VB.NET illustrates the basic idea.

Dim dev As New Eth32()

Try
	dev.Connect("192.168.1.100")
Catch my_error As Eth32Exception
	MsgBox("Error occurred involving the ETH32 device: " & dev.ErrorString(my_error.ErrorCode))
End Try

Error Codes

Error code constants are defined by the EthError enumerator. The following error codes are defined: