On program startup I need to configure a bunch of DIO yet the functions needed to do so return custom error objects rather than exceptions so I'm wondering if the best way to handle this is to 1) Throw my own exception after each failed call (as shown below) or 2) the old fashioned Goto ErrorHandler in place of the Throw and do a Throw from there or 3) something else I'm not familiar with yet.
vb.net Code:
ULStat = DIO24.DConfigPort(PortNum, Direction) If Not ULStat.Value = MccDaq.ErrorInfo.ErrorCode.NoErrors Then errmsg = "Error in ConfigureIO during DIO24.DConfigPort: " & ULStat.Message Throw New ArgumentException(errmsg) End If
Once all this is done I don't care about any other errors from this library elsewhere since they should never occur. It's stuff like "Board not configured", "invalid port number", etc that I need to catch at startup and close the program.




Reply With Quote
