Yes, this is part of a larger script and I throws the expected 403, the problem is that it doesnt send the message. I tried a simpler "print something) and didnt either, so the problem is in how the error is catched isnt it?
In general id would be helpful if you actually include the part that would throw the error.
As nils mentioned, the assignment will never throw an error.
You could check for general Exception and inspect if it really is
openrouteservice.exceptions.ApiError
you are looking for.
But again, without context it’s hard to say what your problem is.