schubergphilis / towerlib

A python library to interface with ansible tower's (awx) api.
MIT License
43 stars 39 forks source link

Error when launching a job: return the error #124

Open Sispheor opened 1 year ago

Sispheor commented 1 year ago

Hello there 👋

When a job fail the current behavior is to only log and return None.

Would it be possible to return the error? Could be useful 😁

Thanks !

Sispheor commented 1 year ago

Maybe raising an exception here as we already have AuthFailed, SSLError, ConnectionError.

costastf commented 1 year ago

Hi @Sispheor , thanks for reporting. It is kind of a chosen pattern to return None in case of error in most of the codebase, like can be seen here https://github.com/schubergphilis/towerlib/blob/f522f53698968e40c790d028f8cfeb4e688b6c50/towerlib/towerlib.py#L264 and many other places. Raising an exception of course also makes sense but it means something completely different and would be a major change. I am not opposed to that just want to put this out there and see whether in other cases where the error is silent is actually the preferred response in which case we need to consider which way to go.

Sispheor commented 1 year ago

Maybe you can set this as config flag (raise_on_error) with default false to match the current behavior.