Source code for labelbox.exceptions

[docs]class LabelboxError(Exception): """Base class for exceptions.""" def __init__(self, message, cause=None): """ Args: message (str): Informative message about the exception. cause (Exception): The cause of the exception (an Exception raised by Python or another library). Optional. """ super().__init__(message, cause) self.message = message self.cause = cause def __str__(self): return self.message + str(self.args)
[docs]class AuthenticationError(LabelboxError): """Raised when an API key fails authentication.""" pass
[docs]class AuthorizationError(LabelboxError): """Raised when a user is unauthorized to perform the given request.""" pass
[docs]class ResourceNotFoundError(LabelboxError): """Exception raised when a given resource is not found. """ def __init__(self, db_object_type, params): """ Constructor. Args: db_object_type (type): A labelbox.schema.DbObject subtype. params (dict): Dict of params identifying the sought resource. """ super().__init__("Resource '%s' not found for params: %r" % (db_object_type.type_name(), params)) self.db_object_type = db_object_type self.params = params
[docs]class ResourceConflict(LabelboxError): """Exception raised when a given resource conflicts with another. """ pass
[docs]class ValidationFailedError(LabelboxError): """Exception raised for when a GraphQL query fails validation (query cost, etc.) E.g. a query that is too expensive, or depth is too deep. """ pass
[docs]class InternalServerError(LabelboxError): """Nondescript prisma or 502 related errors. Meant to be retryable. TODO: these errors need better messages from platform """ pass
[docs]class InvalidQueryError(LabelboxError): """ Indicates a malconstructed or unsupported query (either by GraphQL in general or by Labelbox specifically). This can be the result of either client or server side query validation. """ pass
[docs]class ResourceCreationError(LabelboxError): """ Indicates that a resource could not be created in the server side due to a validation or transaction error""" pass
[docs]class NetworkError(LabelboxError): """Raised when an HTTPError occurs.""" def __init__(self, cause): super().__init__(str(cause), cause) self.cause = cause
[docs]class TimeoutError(LabelboxError): """Raised when a request times-out.""" pass
[docs]class InvalidAttributeError(LabelboxError): """ Raised when a field (name or Field instance) is not valid or found for a specific DB object type. """ def __init__(self, db_object_type, field): super().__init__("Field(s) '%r' not valid on DB type '%s'" % (field, db_object_type.type_name())) self.db_object_type = db_object_type self.field = field
[docs]class ApiLimitError(LabelboxError): """ Raised when the user performs too many requests in a short period of time. """ pass
[docs]class MalformedQueryException(Exception): """ Raised when the user submits a malformed query.""" pass
[docs]class UuidError(LabelboxError): """ Raised when there are repeat Uuid's in bulk import request.""" pass
[docs]class InconsistentOntologyException(Exception): pass
[docs]class MALValidationError(LabelboxError): """Raised when user input is invalid for MAL imports.""" pass
[docs]class OperationNotAllowedException(Exception): """Raised when user does not have permissions to a resource or has exceeded usage limit""" pass
[docs]class ConfidenceNotSupportedException(Exception): """Raised when confidence is specified for unsupported annotation type"""
[docs]class CustomMetricsNotSupportedException(Exception): """Raised when custom_metrics is specified for unsupported annotation type"""
[docs]class ProcessingWaitTimeout(Exception): """Raised when waiting for the data rows to be processed takes longer than allowed"""