I am writing a program that retrieves data from an industrial device and exports it to a MySQL database. For interacting with the device, I am using a DLL driver provided by the manufacturer. In this DLL, there is a custom-made exception which is thrown when there is a communication error or any other type of abnormal situation when communicating with the device.
The problem is that there is a single class exception. So, when I catch an exception of that type, I cannot really tell which particular problem happened since there are several ones (connection timeout, trying to access an invalid memory address, etc.).
So what I am doing for the moment is to use the Exception.Message property. So for example if the exception message contains "Invalid Address" then I know that the error is due to trying to access an illegal address within the device, similarly if the exception message contains "connection timeout" I know that there was an exception timeout. But this approach looks really dangerous since the messages may change in future releases of the DLL.
What can I do to deal with this problem in a better way?