Skip to content

Commit 317ae95

Browse files
author
Matt Sokoloff
committed
add OperationNotAllowedException to catch limits
1 parent 5e92625 commit 317ae95

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

labelbox/client.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ def check_errors(keywords, *path):
201201
return None
202202

203203
def get_error_status_code(error):
204+
print(error)
204205
return error["extensions"]["exception"]["status"]
205206

206207
if check_errors(["AUTHENTICATION_ERROR"], "extensions",
@@ -255,6 +256,12 @@ def get_error_status_code(error):
255256
else:
256257
raise labelbox.exceptions.InternalServerError(message)
257258

259+
not_allowed_error = check_errors(["OPERATION_NOT_ALLOWED"],
260+
"extensions", "code")
261+
if not_allowed_error is not None:
262+
message = not_allowed_error.get("message")
263+
raise labelbox.exceptions.OperationNotAllowedException(message)
264+
258265
if len(errors) > 0:
259266
logger.warning("Unparsed errors on query execution: %r", errors)
260267
raise labelbox.exceptions.LabelboxError("Unknown error: %s" %

labelbox/exceptions.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,4 +112,9 @@ class InconsistentOntologyException(Exception):
112112

113113
class MALValidationError(LabelboxError):
114114
"""Raised when user input is invalid for MAL imports."""
115-
...
115+
pass
116+
117+
118+
class OperationNotAllowedException(Exception):
119+
"""Raised when user does not have permissions to a resource or has exceeded usage limit"""
120+
pass

0 commit comments

Comments
 (0)