Skip to content

Commit

Permalink
Be safer in checking for 403 errors
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisamin committed Nov 23, 2018
1 parent c815fe5 commit e312434
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions ripe/atlas/tools/commands/measure/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,21 +463,21 @@ def _handle_api_error(response):
if isinstance(response, dict) and "detail" in response:
error_detail = response["detail"]

if response.get("error", {}).get("status") == 403:
message = (
"There was a problem communicating with the RIPE Atlas "
"infrastructure. \nStatus is 403 so you probably need an API "
"key. Register and create API Keys at "
"https://atlas.ripe.net/\n"
"Create the new key with the permission Create a new user "
"defined measurement and install using:\n\n"
" ripe-atlas configure --set authorisation.create=MY_API_KEY\n\n"
"The message given was:\n\n {}"
).format(error_detail)

message = (
"There was a problem communicating with the RIPE Atlas "
"infrastructure. The message given was:\n\n {}"
).format(error_detail)

if response["error"]["status"] == 403:
message = (
"There was a problem communicating with the RIPE Atlas "
"infrastructure. \nStatus is 403 so you probably need an API "
"key. Register and create API Keys at "
"https://atlas.ripe.net/\n"
"Create the new key with the permission Create a new user "
"defined measurement and install using:\n\n"
" ripe-atlas configure --set authorisation.create=MY_API_KEY\n\n"
"The message given was:\n\n {}"
).format(error_detail)

raise RipeAtlasToolsException(message)

0 comments on commit e312434

Please sign in to comment.