Skip to content

Commit 1fa9b9a

Browse files
author
kbehrman
committed
Merge pull request shotgunsoftware#17 from shotgunsoftware/api_access_denied_error
additional custom protocol error message handling
2 parents 25b4b41 + 35bd3de commit 1fa9b9a

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

‎shotgun_api3/shotgun.py‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1255,8 +1255,10 @@ def _call_rpc(self, method, params, include_script_name=True, first=False):
12551255
try:
12561256
self._parse_http_status(http_status)
12571257
exceptProtocolError, e:
1258-
ife.errcode==503:
1259-
e.reason="Shotgun is currently down for maintenance. Please try again later."
1258+
e.headers=resp_headers
1259+
# 403 is returned with custom error page when api access is blocked
1260+
ife.errcode==403:
1261+
e.errmsg+=": %s"%body
12601262
raise
12611263

12621264
response=self._decode_response(resp_headers, body)
@@ -1385,16 +1387,16 @@ def _parse_http_status(self, status):
13851387
:param status: Tuple of (code, reason).
13861388
"""
13871389
error_code=status[0]
1388-
reason=status[1]
1390+
errmsg=status[1]
13891391

13901392
ifstatus[0] >=300:
1391-
msg="HTTP error from server"
1393+
headers="HTTP error from server"
13921394
ifstatus[0] ==503:
1393-
reason="Shotgun is currently down for maintenance. Please try again later."
1395+
errmsg="Shotgun is currently down for maintenance. Please try again later."
13941396
raiseProtocolError(self.config.server,
13951397
error_code,
1396-
reason,
1397-
msg)
1398+
errmsg,
1399+
headers)
13981400

13991401
return
14001402

0 commit comments

Comments
(0)