Although the DigitalOcean API spec says that the error message will be in
the field 'message', I was getting some in the field 'error_message'. This
was happening with a HTTP error code of 404 so the current code was not
catching it.
The raise DoError(json['message') actually raised an exception, namely
KeyError: message. In the Ansible module, this was giving the very
unhelpful error { "failed": true, "msg": "message" }.
This commit adds some error handling to the error handling.
Although the DigitalOcean API spec says that the error message will be in the field 'message', I was getting some in the field 'error_message'. This was happening with a HTTP error code of 404 so the current code was not catching it.
The
raise DoError(json['message')
actually raised an exception, namelyKeyError: message
. In the Ansible module, this was giving the very unhelpful error{ "failed": true, "msg": "message" }
.This commit adds some error handling to the error handling.