Skip to content

Commit 7cbc85c

Browse files
authored
Merge pull request #319 from Labelbox/ms/not-allowed-exception
add OperationNotAllowedException to catch limits
2 parents ef6b006 + 091b56a commit 7cbc85c

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

labelbox/client.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,12 @@ def get_error_status_code(error):
255255
else:
256256
raise labelbox.exceptions.InternalServerError(message)
257257

258+
not_allowed_error = check_errors(["OPERATION_NOT_ALLOWED"],
259+
"extensions", "code")
260+
if not_allowed_error is not None:
261+
message = not_allowed_error.get("message")
262+
raise labelbox.exceptions.OperationNotAllowedException(message)
263+
258264
if len(errors) > 0:
259265
logger.warning("Unparsed errors on query execution: %r", errors)
260266
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)