UDT Tutorial: Error Handling |
Checking return value is never the right way to detect errors in UDT. Instead, the only error detection method is to catch exceptions. The CUDTException class is used to record and provide error information.
To read the detail descriptions of the errors or exceptions, getErrorMessage should be used. UDT also records the system errno for application to processing the exceptions.
There are 6 major categories of exceptions, and
some minor categories in each major category. The major categories are:
1: network setup exception
2: network connection broken
3: memory exception
4: file exception
5: method not supported
6+: undefined error
CUDT udt;
try { // UDT_PCH has been set to false. udt.open(21); //it is trying to open an illegal port } catch (CUDTException e) { // process error... cout << "error message: " << e.getErrorMessage() << endl; } |
In the example above, the output will be:
error message: Couldn't set up network connection: Permission denied. |