Why return value on error rather than raise exception?
Opened this issue · 1 comments
why don't raise value immediately in requestor.py if the request didn't return successful result? instead of checking it manually (by the user of this library manually) ?
response.status_code == 200:
try:
return response.json()
except ValueError:
# GET /system/version
return response.text
else:
return { # <------ why not raise exception?
'reason': response.reason,
'status_code': response.status_code,
'url': response.request.url
}
why not raise ValueError("eror ...")
? so that the user know something wrong happened.
With current design we need to check every time if the response contains 'status_code' or not.
Thanks for admin-api
.
Any reason behind this approach?
Boto3 always raise exception when the server return anything other than 200
, so we as boto3 user not need to figure out if our response contain successful result or not. We just wrap it with try-except
and just print to user the except
result (that we get from boto3).
But I don't have any clue on how to get detailed request error from Clodian (boto3/s3api has very detailed error on specific operation). I've tried several kind of the predefined error description below. But all I get only "BAD REQUEST", without additional info in response body of "what really happened".
Returning "bad request" to user indeed didn't help. I don't know how to get helpful message e.g "Missing required parameters : {groupId, userType, userStatus}", "Invalid user type. Valid values {admin, user, all}"