From tracing the code, this would unwrap all the way to RemoteException. However, that exception only contains hthe underlying server exception in the form of its error message without the actual exception object. That means we cannot recover exactly what the original exception is, we can only get the error message from it.

We can regenerate the exception by parsing the messages. Then this method would be changed to not just unwrap the exception, but it will throw an recovered SQLException if it can find one, or throw a generic PhoenixIOException if it cannot recover the SQL state and error code from the messages.