Source code for encord.exceptions

#
# Copyright (c) 2020 Cord Technologies Limited
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.


[docs]class EncordException(Exception): """Base class for all exceptions.""" def __init__(self, message): super().__init__(message) self.message = message def __str__(self): return self.message
CordException = EncordException
[docs]class InitialisationError(EncordException): """Exception thrown when API key fails to initialise.""" pass
[docs]class AuthenticationError(EncordException): """Exception thrown when API key fails authentication.""" pass
[docs]class AuthorisationError(EncordException): """ Exception thrown when access is unauthorised. (E.g. access to a data asset or method). """ pass
[docs]class ResourceNotFoundError(EncordException): """ Exception thrown when a requested resource is not found. (E.g. label, data asset). """ pass
[docs]class TimeOutError(EncordException): """Exception thrown when a request times out.""" pass
[docs]class RequestException(EncordException): """Ambiguous exception while handling request.""" pass
[docs]class UnknownException(EncordException): """Unknown error.""" pass
[docs]class InvalidDateFormatError(EncordException): """Invalid date format error""" pass
[docs]class MethodNotAllowedError(EncordException): """Exception thrown when HTTP method is not allowed.""" pass
[docs]class OperationNotAllowed(EncordException): """ Exception thrown when a read/write operation is not allowed. The API key blocks the operation. """ pass
[docs]class AnswerDictionaryError(EncordException): """ Exception thrown when answer dictionaries are incomplete. Occurs when an object or classification is missing. """ pass
[docs]class CorruptedLabelError(EncordException): """ Exception thrown when a label is corrupted. (E.g. the frame labels have more frames than the video). """ pass
[docs]class FileTypeNotSupportedError(EncordException): """ Exception thrown when a file type is not supported. Supported file types are: image/jpeg, image/png, video/webm, video/mp4. """ pass
[docs]class FileSizeNotSupportedError(EncordException): """ Exception thrown when the combined size of the input files is larger than the supported limit. """ pass
[docs]class FeatureDoesNotExistError(EncordException): """ If a feature uid does not exist in a given project ontology. """ pass
[docs]class ModelWeightsInconsistentError(EncordException): """ Exception thrown when an attempted model training iteration has a different type of weights than what is recorded (i.e. if type of model_hash (uid) is faster_rcnn, but is attempted trained with yolov5 weights). """ pass
[docs]class ModelFeaturesInconsistentError(EncordException): """ If a feature type is different than what is supported by the model (e.g. if creating a classification model using a bounding box). """ pass
[docs]class UploadOperationNotSupportedError(EncordException): """Exception thrown when trying to upload a video/image group to non-Encord storage dataset""" pass
[docs]class DetectionRangeInvalidError(EncordException): """ Exception thrown when a detection range is invalid. (E.g. negative or higher than num frames in video). """ pass
[docs]class InvalidAlgorithmError(EncordException): """Exception thrown when invalid labeling algorithm name is sent.""" pass
[docs]class ResourceExistsError(EncordException): """ Exception thrown when trying to re-create a resource. Avoids overriding existing work. """ pass
[docs]class DuplicateSshKeyError(EncordException): """ Exception thrown when using an SSH key that was added twice to the platform. """ pass
[docs]class SshKeyNotFound(EncordException): """ Exception thrown when using an SSH key that was not added to the platform. """
[docs]class InvalidArgumentsError(EncordException): """Exception thrown when the arguments are invalid.""" pass
[docs]class GenericServerError(EncordException): """ The server has reported an error which is not recognised by this SDK version. Try upgrading the SDK version to see the precise error that is reported. """ pass
[docs]class CloudUploadError(EncordException): """ The upload to the cloud was not successful """ pass
[docs]class MultiLabelLimitError(EncordException): """ Too many labels were requested """ def __init__(self, message, maximum_labels_allowed: int): super().__init__(message=message) self.maximum_labels_allowed = maximum_labels_allowed