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.
If you see the implementation hive Exception implementation, It simply inherited
ExceptionSo it has exception details in the format of string only that looks like somewhatjsonthat actually confuse us and we hope to access it using an instance variable or as a dictionary but in reality it is just string that looks likejson.But We can use the reguler expression to extract details as we wish like
errortypeetc.