Added missing type cast in exception handlers for communication errors (Closes #39)