I'm facing an exception similar to this one and I'm trying to handle it based on the error itself.
The problem is that pyhive.exc.OperationalError
is very generic and handles errors from timeouts to non-existent tables so I would need the exact value from the errorMessage
part in order to handle each error type differently, like if it's a timeout, wait and retry; if it's something else, handle it differently and so on.
If I catch the error as except OperationalError as e
, how would I extract the errorMessage
part? I could parse the string representation (e.__str__()
) but that seems weird as I'm sure there's a proper way.
you can extract the errorMessage this way
you can use
dir(e)
to find the methods and dunder methods for each object. which will allow you to see what methods you can call to access the data.