jesper-raemaekers / python-polarion

A Python package to access the Polarion WSDL API.
MIT License
54 stars 34 forks source link

The script throws Exception and masking the original exception #180

Open LocutusGrax opened 3 weeks ago

LocutusGrax commented 3 weeks ago

The script throws Exception when you get a login failure. Exception is borad exeption.

I need to be able to catch the real exception in my script, need to be able to handle login failure. A way to update code :

except Exception as e:
    # some code
    raise e
WH-Yoshi commented 2 weeks ago

Seen that exception thrown from the Polarion server aren't defined into Python as a common class, it's Zeep that handle the Exceptions. Zeep throws a Fault that nest the web-service Exception for us.

The exact Exception thrown by Polarion in the Zeep client looks like this : com.polarion.platform.security.AuthenticationFailedException An idea to grab the Exception would be to do smth like this :

try:
    # <your code>
except Exception as e:
    if "com.polarion.platform.security.AuthenticationFailedException" in str(e):
        raise NotBroadException(e)
    else:
        raise Exception(e)