# pylint: disable-msg=too-few-public-methods,too-many-lines
# -*- coding: utf-8 -*-
"""
Module realizes a list of errors
"""
import inspect
from typing import Dict, Union
from ..constants.errors import ERROR_LINK
[docs]class ErrorInfo:
"""
VL error.
Attributes:
errorCode: error code
description: short error description
detail: full error description
"""
__slots__ = ["errorCode", "description", "detail"]
def __init__(self, code: int, description: str, detail: str):
self.errorCode = code
self.description = description
self.detail = detail
def __eq__(self, other):
return isinstance(other, ErrorInfo) and self.errorCode == other.errorCode
def __hash__(self):
return hash((self.errorCode, self.description, self.detail))
def __repr__(self):
return str(self.asDict())
@property
def link(self) -> str:
"""
Get link with error info.
"""
return ERROR_LINK.format(self.errorCode)
[docs] def asDict(self) -> Dict:
"""
Convert error to dict.
Returns:
dict with keys "error_code", "desc", "detail", "link"
"""
return {"error_code": self.errorCode, "desc": self.description, "detail": self.detail, "link": self.link}
[docs] @classmethod
def fromDict(cls, error: Dict[str, Union[int, str]]) -> "ErrorInfo":
"""
Convert dict to error.
Args:
error: dict with keys "error_code", "desc", "detail"
Returns:
ErrorInfo instance
"""
return cls(error["error_code"], error["desc"], error["detail"])
[docs]class LunaCoreError:
"""
Structure to save errors in LUNA Core.
"""
# !!!!!!!!!!!!!! DON'T USE core errors in luna python services !!!!!!!!!!!!!!!!!
BadConfig = ErrorInfo(100, "Bad/incomplete configuration", "{}")
BadQuery = ErrorInfo(101, "Bad/incomplete query", "{}")
BadBody = ErrorInfo(102, "Bad/incomplete body", "{}")
OutOfMemoryError = ErrorInfo(105, "Out of memory", "{}")
InvalidHttpRequest = ErrorInfo(106, "Invalid http request", "{}")
GenericError = ErrorInfo(200, "Generic error", "{}")
# message subsystem
BadMessage = ErrorInfo(2000, "Bad/incomplete message package", "{}")
CoreBadContentType = ErrorInfo(2001, "Bad/unsupported message content type", "{}")
WorkerCallFailed = ErrorInfo(2002, "Failed to call a remote worker", "{}")
DriverCallFailed = ErrorInfo(2003, "Failed to call a driver method", "{}")
GenericMQError = ErrorInfo(2004, "Generic MQ error", "{}")
#: bindings error
BindingsNotReady = ErrorInfo(2101, "Data not ready", "{}")
DriverStopped = ErrorInfo(2102, "Driver is stopped", "{}")
ConsumeAmountExceeded = ErrorInfo(2103, "Max amount of messages in a queue exceeded", "{}")
QueueDriverCallFailed = ErrorInfo(2104, "Queue driver call failed", "{}")
# descriptor match
MatchDescriptors = ErrorInfo(5003, "Failed to match descriptors", "{}")
MatchBadInput = ErrorInfo(5004, "Bad/incomplete input data", "{}")
InvalidConfig = ErrorInfo(5005, "Invalid config", "{}")
ReferenceMissingUuid = ErrorInfo(5101, "Reference uuid is missing", "Reference uuid is missing")
ReferenceNotExtractedUuid = ErrorInfo(
5102, "Reference uuid has no extracted descriptor", "Reference uuid has no extracted descriptor"
)
UnsupportedApi = ErrorInfo(7001, "Bad/unsupported API version", "{}")
[docs]class DataBaseError:
"""
Database errors
"""
ExecuteError = ErrorInfo(10015, "SQL error", "SQL request execution failed")
PingDataBaseError = ErrorInfo(10016, "Database error", "Could not connect to database")
DataBaseConnectionTimeoutError = ErrorInfo(10017, "Database error", "Database connection timeout error")
OtherDatabaseError = ErrorInfo(10018, "Database error", "{}")
[docs]class LunaApiError:
"""
Luna Api errors
"""
RequestInternalServerError = ErrorInfo(11009, "Internal server error", "Internal server error")
ObjectNotFound = ErrorInfo(11020, "Object not found", "One or more {} not found")
FailDownloadImage = ErrorInfo(11027, "External request failed", "Failed to download image by url '{}'")
BadContentTypeDownloadedImage = ErrorInfo(11028, "Bad/incomplete input data", "Bad content type of image '{}'")
BadContentTypeInMultipartImage = ErrorInfo(
11029, "Bad/incomplete input data", "Bad content type of image in multipart body"
)
BadWarpImageSize = ErrorInfo(11030, "Bad/incomplete input data", "Image size is not equal to 250x250")
SampleNotFound = ErrorInfo(11031, "Bad/incomplete input data", "Sample with id {} not found")
FaceDoesNotHaveAttributes = ErrorInfo(11032, "Object not found", "Face with id {} does not have attributes yet")
DescriptorNotExtracted = ErrorInfo(11034, "Bad/incomplete input data", "Descriptor for {} '{}' was not extracted")
ServiceNameNotFound = ErrorInfo(11035, "Service name not found", "Service name {} not found")
ForbiddenRootRequestFound = ErrorInfo(
11036, "Forbidden", "Luna-Account-Id header is required for requests which change the state of system"
)
BadAccountId = ErrorInfo(
11037,
"Bad/incomplete input data",
"Luna-Account-Id header is not UUID, format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
)
MultipleFaces = ErrorInfo(11038, "Multiple faces found", "Multiple faces found in image {} , detect {}")
LunaTasksIsDisabled = ErrorInfo(11039, "Forbidden", "Luna Tasks service is disabled")
LunaEventsIsDisabled = ErrorInfo(11040, "Forbidden", "Luna Events service is disabled")
NoOneFaceFoundByExternalId = ErrorInfo(11041, "Object not found", "No one face found with external id {}")
UnknownErrorLoopError = ErrorInfo(11042, "Internal server error", "Unhandled exception: {}")
BadWarpImage = ErrorInfo(11043, "Bad/incomplete input data", "{}")
ForbiddenProcess = ErrorInfo(11044, "Forbidden", "{} turned off on luna-api instance")
OnlyOneDetectionRectAvailable = ErrorInfo(
11045, "Forbidden", "Only one detection rect for each image available at the moment"
)
MultiplieSameImageNames = ErrorInfo(11046, "Bad/incomplete input data", "More than one file named {} found")
BoundingBoxNotAvailableForWarp = ErrorInfo(
11047, "Bad/incomplete input data", "Bounding box not available for warp images"
)
MultiplieSameBoundingBoxes = ErrorInfo(
11048, "Bad/incomplete input data", "Multiplie bounding boxes lists in request"
)
BadMultipartInput = ErrorInfo(11049, "Bad/incomplete input data", "{}")
MultiplieSameBoundingBox = ErrorInfo(
11050, "Bad/incomplete input data", "More than one bounding box for image named {} found"
)
StaticNotFoundError = ErrorInfo(11051, "Internal server error", "Service 'static' folder not being loaded")
NotSelectedAttributesForExtract = ErrorInfo(
11052, "Bad/incomplete input data", "No one attributes was settled for the extract"
)
MultipleHuman = ErrorInfo(
11053, "Multiple human bodies found", "Multiple human bodies found on image {} , detect {}"
)
LivenessIsDisabled = ErrorInfo(11054, "Forbidden", "Liveness service is disabled")
LicenseProblem = ErrorInfo(11055, "Forbidden", "License problem: '{}'")
InvalidRequest = ErrorInfo(11056, "Bad/incomplete input data", "{}")
NoOneEventFoundByExternalId = ErrorInfo(11057, "Object not found", "No one event found with external id {}")
NoOneEventFoundByTrackId = ErrorInfo(11058, "Object not found", "No one event found with track id {}")
ForbiddenByToken = ErrorInfo(
11059, "Forbidden", "Request denied due to token restrictions, required '{}' permission for '{}'"
)
ResourceForbiddenByToken = ErrorInfo(
11060,
"Forbidden",
"Access to the resource is denied due to token restrictions. Required '{}' resource permission",
)
AccountIdAuthDisabled = ErrorInfo(11061, "Forbidden", "Authorization with 'Luna-Account-Id' header is disabled")
AccountTokenPermissionError = ErrorInfo(11062, "Forbidden", "Specified token corrupted")
AccountQueryPermissionError = ErrorInfo(
11063,
"Forbidden",
"The query parameter `account_id` usage denied due to account restrictions",
)
PermissionByTokenDenied = ErrorInfo(
11064,
"Forbidden",
"Access to the resource is denied using authorization by token",
)
AuthorizationFailed = ErrorInfo(11065, "Authorization failed", "{}")
LunaAccountIdHeaderNotFound = ErrorInfo(11066, "Bad/incomplete input data", "Luna-Account-Id header not found")
ForbiddenByTokenEmitEvents = ErrorInfo(
11067,
"Forbidden",
"Request denied due to token restrictions. "
"According to `emit_events` the handler is not whitelisted or handler is blacklisted.",
)
ForbiddenByTokenEventsGeneration = ErrorInfo(
11068,
"Forbidden",
"Request denied due to token restrictions. Events generation is not allowed",
)
ForbiddenVisibilityAreaDenied = ErrorInfo(
11069,
"Forbidden",
"Account id specified in {} is different from requester account id, "
"that is not acceptable due to account/token visibility area restrictions",
)
[docs]class RESTAPIError:
"""
Rest api common errors
"""
RequestNotContainsJson = ErrorInfo(12002, "Bad/incomplete input data", "Request does not contain json")
FieldNotInJSON = ErrorInfo(12003, "Bad/incomplete input data", "Field '{}' not found in json")
EmptyJson = ErrorInfo(12005, "Bad/incomplete input data", "Request contain empty json")
BadHeaderAuth = ErrorInfo(
12010, "Bad/incomplete input data", 'This resource needs "Authorization" authorization headers'
)
BadQueryParams = ErrorInfo(12012, "Bad/incomplete input data", "Bad query parameters '{}'")
PageNotFoundError = ErrorInfo(12013, "Resource not found", "Page not found")
QueryParameterNotFound = ErrorInfo(12014, "Bad/incomplete input data", "Required parameters '{}' not found")
RequiredQueryParameterNotFound = ErrorInfo(12016, "Bad/incomplete input data", "No one parameters '{}' not found")
BadContentType = ErrorInfo(12017, "Bad/incomplete input data", "Bad content type")
MethodNotAllowed = ErrorInfo(12021, "Method not allowed", "Method not allowed")
BadInputJson = ErrorInfo(
12022, "Bad/incomplete input data", "Failed to validate input json. Path: '{}', message: '{}'"
)
NotAcceptable = ErrorInfo(12023, "Bad/incomplete input data", "Content type is unacceptable, allowed types: '{}'")
UnsupportedMediaType = ErrorInfo(12024, "Bad/incomplete input data", "Unsupported media type")
SpecifiedTypeNotMatchDataType = ErrorInfo(
12025, "Bad/incomplete input data", "Specified content type does not match data type"
)
InvalidInputJson = ErrorInfo(12027, "Bad/incomplete input data", "Failed to validate input json. Message: '{}'")
BadInputFlat = ErrorInfo(12028, "Bad/incomplete input data", "Failed to parse Flatbuf")
NotImplementedError = ErrorInfo(
12029, "Functionality is not implemented", "Required server functionality is not implemented"
)
NotContainsData = ErrorInfo(12030, "Bad/incomplete input data", "Request does not contain data")
BadInputData = ErrorInfo(12031, "Bad/incomplete input data", "{}")
DocumentNotFoundError = ErrorInfo(12032, "Internal server error", "Document file not found")
ForbiddenError = ErrorInfo(12033, "Forbidden", "Access to this resource on the server is denied")
InvalidDescriptorLength = ErrorInfo(12034, "Bad/incomplete input data", "Descriptor has incorrect length {}")
BadInputXpk = ErrorInfo(12035, "Bad/incomplete input data", "Failed to parse xpk file")
UnknownDescriptorVersion = ErrorInfo(
12036, "Bad/incomplete input data", "Descriptor version {} is not registered in the system"
)
XpkDoesNotContainDescriptor = ErrorInfo(12037, "Bad/incomplete input data", "XPK file does not contain descriptor")
BadSdkDescriptor = ErrorInfo(12038, "Bad/incomplete input data", "SDK descriptor is not valid")
UnknownMultipartName = ErrorInfo(12039, "Bad/incomplete input data", "Unknown multipart name '{}'")
DuplicateMultipartName = ErrorInfo(12040, "Bad/incomplete input data", "Duplicate multipart name '{}'")
BadMultipartContentType = ErrorInfo(
12041, "Bad/incomplete input data", "Multipart with name '{}' has bad Content-Type"
)
GoneError = ErrorInfo(12042, "Gone", "Access to this resource on the server is no longer available")
UnknownServiceError = ErrorInfo(12043, "Unknown error", "Service '{}' unknown error, method: '{}', url: '{}'")
InvalidInputGzip = ErrorInfo(
12044, "Bad/incomplete input data", "Failed to decompress input body using gzip encoder"
)
InvalidInputDeflate = ErrorInfo(
12045, "Bad/incomplete input data", "Failed to decompress input body using deflate encoder"
)
[docs]class LunaImageStoreError:
"""
Luna-image-store errors
"""
ImageNotFoundError = ErrorInfo(13003, "Object not found", "Image with id '{}' not found")
ImageCountExceededLimit = ErrorInfo(13004, "Bad/incomplete input data", "Image count exceeded limit 1000")
BucketNotFound = ErrorInfo(13005, "Object not found", "Bucket with name '{}' not found")
BucketAlreadyExist = ErrorInfo(13006, "Unique constraint error", "Bucket with name '{}' already exist")
ObjectInBucketNotFound = ErrorInfo(13007, "Object not found", "Object with id '{}' not found")
ObjectInBucketAlreadyExist = ErrorInfo(13008, "Unique constraint error", "Object with id '{}' already exist")
ObjectInBucketCountExceededLimit = ErrorInfo(13009, "Bad/incomplete input data", "Object count exceeded limit 1000")
[docs]class LunaAdmin:
"""
Luna-admin errors
"""
AccountNotFound = ErrorInfo(15012, "Object not found", "Account with id '{}' not found")
EmailOrIdAlreadyExist = ErrorInfo(15013, "Unique constraint error", "Account with same email or id already exist")
BadAdminAuth = ErrorInfo(15014, "Bad/incomplete input data", "Login or password is incorrect")
PermissionDenied = ErrorInfo(15015, "Bad/incomplete input data", "Admin account type required")
[docs]class ImageProcessingError:
"""Image processing errors"""
ConvertBase64Error = ErrorInfo(18001, "Bad/incomplete input data", "Failed convert data from base64 to bytes")
ConvertImageError = ErrorInfo(18002, "Bad/incomplete input data", "Failed convert bytes to {}")
ReadImageError = ErrorInfo(18003, "Bad/incomplete input data", "Failed read bytes as image")
[docs]class LocalStoreError:
"""Image Store errors"""
SavingImageErrorLocal = ErrorInfo(19001, "Internal server error", "Failed to save image in the storage")
DeleteImageErrorLocal = ErrorInfo(19002, "Internal server error", "Failed to remove image from the storage")
DeleteImagesErrorLocal = ErrorInfo(19003, "Internal server error", "Failed to remove image from the storage")
CreateBucketErrorLocal = ErrorInfo(19004, "Internal server error", "Failed to create bucket")
GettingBucketsErrorLocal = ErrorInfo(19005, "Internal server error", "Failed to get bucket list")
GettingImageErrorLocal = ErrorInfo(19006, "Internal server error", "Failed to get image from the storage")
SavingObjectErrorLocal = ErrorInfo(19007, "Internal server error", "Failed to save object in the storage")
DeleteObjectErrorLocal = ErrorInfo(19008, "Internal server error", "Failed to remove object from the storage")
DeleteObjectsErrorLocal = ErrorInfo(19009, "Internal server error", "Failed to remove objects from the storage")
GettingObjectErrorLocal = ErrorInfo(19010, "Internal server error", "Failed to get object from the storage")
GettingObjectsErrorLocal = ErrorInfo(19011, "Internal server error", "Failed to get objects from the storage")
DeleteBucketErrorLocal = ErrorInfo(19012, "Internal server error", "Failed to delete bucket")
[docs]class S3StorageError:
"""
S3 errors
"""
SavingImageErrorS3 = ErrorInfo(20001, "Internal server error", "Failed to save image in the storage")
DeleteImageErrorS3 = ErrorInfo(20002, "Internal server error", "Failed to remove image from the storage")
DeleteImagesErrorS3 = ErrorInfo(20003, "Internal server error", "Failed to remove image from the storage")
CreateBucketErrorS3 = ErrorInfo(20004, "Internal server error", "Failed to create bucket")
RequestS3Error = ErrorInfo(20005, "Internal server error", "Request to S3 Failed")
RequestS3Forbidden = ErrorInfo(20006, "Internal server error", "Request to S3 Forbidden")
RequestTimeoutToS3Error = ErrorInfo(
20007, "Internal server error", "Request time to S3 is longer than the established time"
)
S3ConnectionRefusedError = ErrorInfo(20008, "Internal server error", "S3 Connection Refused")
ConnectTimeoutToS3Error = ErrorInfo(
20009, "Internal server error", "Connect time to S3 is longer than the established time"
)
S3UnknownError = ErrorInfo(20010, "Internal server error", "Unknown s3 error")
GettingBucketsErrorS3 = ErrorInfo(20011, "Internal server error", "Failed to get bucket list")
GettingImageErrorS3 = ErrorInfo(20012, "Internal server error", "Failed to get image from the storage")
SavingObjectErrorS3 = ErrorInfo(20013, "Internal server error", "Failed to save object in the storage")
DeleteObjectErrorS3 = ErrorInfo(20014, "Internal server error", "Failed to remove object from the storage")
DeleteObjectsErrorS3 = ErrorInfo(20015, "Internal server error", "Failed to remove object list from the storage")
GettingObjectErrorS3 = ErrorInfo(20016, "Internal server error", "Failed to get object from the storage")
GettingObjectsErrorS3 = ErrorInfo(20017, "Internal server error", "Failed to get object list from the storage")
DeleteBucketsErrorS3 = ErrorInfo(20018, "Internal server error", "Failed to delete bucket")
BucketNameErrorS3 = ErrorInfo(20019, "Bad/incomplete query", "Failed to create bucket with specified name")
[docs]class LunaFaces:
"""
Luna-faces error
"""
FaceWithAttributeAlreadyExist = ErrorInfo(
22001, "Unique constraint error", "Face with the same attribute_id already exists"
)
FaceNotFound = ErrorInfo(22002, "Object not found", "Face with id '{}' not found")
ListNotFound = ErrorInfo(22003, "Object not found", "List with id '{}' not found")
FacesNotFound = ErrorInfo(22004, "Object not found", "One or more faces not found, including face with id '{}'")
ListsNotFound = ErrorInfo(22005, "Object not found", "One or more lists not found, including list with id '{}'")
FaceAvatarIsNotValidUrl = ErrorInfo(22009, "Bad/incomplete configuration", "Face avatar url is not correct")
AttributesForUpdateNotFound = ErrorInfo(22010, "Object not found", "Attributes with id '{}' for update not found")
AttributesNotFound = ErrorInfo(22011, "Object not found", "Attributes with id {} not found")
FailDecodeDescriptor = ErrorInfo(22012, "Bad/incomplete input data", "Failed to decode descriptor from base64")
FailEncodeDescriptor = ErrorInfo(22013, "Bad/incomplete input data", "Failed to encode descriptor to base64")
WrongAttributesGeneration = ErrorInfo(
22015, "Conflict input data", "Attribute '{}' generation should be '{}', but '{}' was provided"
)
BadTargetsToGetFaces = ErrorInfo(
22016, "Bad input data", "'{}' is not valid target to get faces. Valid target should be one of {}."
)
BadMatchReferenceCase = ErrorInfo(
22017,
"Bad/incomplete input data",
"Match reference must be specified either as (descriptor) or (attribute_id) or (face_id)",
)
DescriptorNotFound = ErrorInfo(
22018, "Object not found", "Face descriptor of version {} is not found for object with id '{}'."
)
AttributeCorrupted = ErrorInfo(22020, "Internal server error", "Corrupted attribute with id '{}'")
AttributeAlreadyExist = ErrorInfo(22021, "Integrity error", "Attribute with id '{}' already exist")
AttributeDoesNotContainAnyData = ErrorInfo(
22022, "Bad input data", "Attribute does not contain 'descriptors' and 'basic_attributes'"
)
AttributeContainsSamplesWithoutData = ErrorInfo(
22023, "Bad input data", "Attribute contains '{}' samples but corresponding attributes is empty"
)
AttributeWithDescriptorsIdenticalVersion = ErrorInfo(
22024, "Bad input data", "Attribute contains descriptors of identical versions: '{}'"
)
FaceSampleConflict = ErrorInfo(
22025, "Conflict input data", "Attribute samples of face (face_id '{}') do not match specified ones"
)
ListAlreadyExist = ErrorInfo(22026, "Unique constraint error", "List with id '{}' already exist")
[docs]class LunaEvents:
"""
Luna-events error
"""
EventNotFound = ErrorInfo(23001, "Object not found", "Event with id {} not found")
EventsNotFound = ErrorInfo(23002, "Object not found", "One or more events not found, including event with id {}")
EventAlreadyExist = ErrorInfo(23003, "Unique constraint error", "One or more event id from '{}' already exist")
EventAttributeIdAlreadyExist = ErrorInfo(
23004, "Unique constraint error", "One or more attribute id from '{}' already exist"
)
BadTargetsToGetEvents = ErrorInfo(
23005, "Bad input data", "'{}' is not valid target to get events. Valid events should be one of {}"
)
EventSaveTimeout = ErrorInfo(
23006, "Internal server error", "Timeout ({} seconds) for saving events into history database has been expired"
)
HumanDescriptorNotFound = ErrorInfo(
23007, "Object not found", "Human descriptor of version {} is not found for object with id '{}'."
)
CopywriterQueueIsFull = ErrorInfo(23008, "Internal server error", "Copywriter queue is full")
EventsAreShuttingDown = ErrorInfo(23009, "Internal server error", "Events are shutting down")
EventsSavingFailed = ErrorInfo(23010, "Internal server error", "Events saving failed, reason: {}")
BadEventDeletionTargets = ErrorInfo(
23011, "Bad input data", "'{}' is not valid target for event deletion info. Valid target should be one of {}"
)
[docs]class LIMIndexer:
"""
LIM indexer errors.
"""
InternalError = ErrorInfo(26100, "Internal server error", "Internal server error")
IndexerBusy = ErrorInfo(26101, "Indexer busy", "Indexer busy")
BuildFailed = ErrorInfo(26103, "Build failed", "Build failed")
BuildProcessDied = ErrorInfo(26104, "Build process failed", "Build process died")
EmptyList = ErrorInfo(26105, "Build process failed", "List is empty")
BuildProcessCancelled = ErrorInfo(26106, "Build process cancelled", "Build process cancelled")
MissingList = ErrorInfo(26107, "Build process failed", "List not found")
DuplicateIndex = ErrorInfo(26108, "Build process failed", "Index with specified ID already exists")
[docs]class LIMManager:
"""
LIM manager errors
"""
IndexingTaskDuplicate = ErrorInfo(26201, "Task duplicate", "Indexing task already exists")
IndexAlreadyBuilt = ErrorInfo(26202, "Index duplicate", "Index for the most recent content version already exists")
IndexerRestarted = ErrorInfo(26203, "Internal server error", "Indexer was restarted for internal reasons")
IndexNotFound = ErrorInfo(26204, "Object not found", "Index with id '{}' not found in the storage")
[docs]class LIMMatcher:
"""
LIM matcher errors
"""
BadMatchingRequest = ErrorInfo(26301, "Bad/incomplete input data", "Failed to validate matching request: {}")
DescriptorLoadError = ErrorInfo(26302, "Bad/incomplete input data", "Failed to load descriptor bytes. {}")
MatchingInternalError = ErrorInfo(26303, "Internal server error", "Failed to search descriptor. {}")
MatchingIndexNotFound = ErrorInfo(26304, "Index not found", "Index for label {} not found.")
DescriptorVersionMismatch = ErrorInfo(
26305, "Descriptor version mismatch", "Descriptor of version {} cannot be searched in index of version {}"
)
IndexStorageDamaged = ErrorInfo(
26306, "Index processing internal error", "Skip load index for label {} due to index storage damage"
)
InsufficientMemory = ErrorInfo(
26307, "Index processing internal error", "Skip load index for label {} due to insufficient memory"
)
IndexCorrupted = ErrorInfo(
26308, "Index processing internal error", "Skip load index for label {} due to index corruption"
)
[docs]class IndexManagerError:
"""
Index manager errors
"""
IndexTaskNotFound = ErrorInfo(26001, "Object not found", "Index task not found")
GenerationNotFound = ErrorInfo(26002, "Internal server error", "Generation not found in indexer")
UnknownStatusOfIndexer = ErrorInfo(26003, "Internal server error", "Not expected status of indexer")
FailedUploadIndex = ErrorInfo(
26004, "Internal server error", "Failed start upload generation {} on daemon {}, reason: {}"
)
FailedReloadIndex = ErrorInfo(
26005, "Internal server error", "Failed start reload generation {} on daemon {}, reason: {}"
)
BadStatusOfUploadTask = ErrorInfo(
26007, "Internal server error", "Not expected status of upload task. Status: {}, daemon: {}, generation: {}"
)
BadStatusOfRestartTask = ErrorInfo(
26008, "Internal server error", "Not expected status of restart task. Status: {}, daemon: {}, generation: {}"
)
ListNotSatisfyIndexationCondition = ErrorInfo(
26009, "Bad/incomplete input data", "List does not satisfy to the indexation condition"
)
[docs]class ConfiguratorError:
"""
Luna-configurator errors.
"""
SettingNotFound = ErrorInfo(27001, "Object not found", "Setting with id '{}' not found")
SettingIntegrityError = ErrorInfo(
27002, "Integrity error", "Setting with the following fields already exists: name: {} tag: {}"
)
FailedCheckConnectionToService = ErrorInfo(
27003, "Bad/incomplete input data", "Connection check to service is failed"
)
NotAllowedToChangeDefaultSettingTags = ErrorInfo(
27004, "Bad/incomplete input data", "Not allowed to change tags for default setting"
)
TagNotFound = ErrorInfo(27005, "Bad/incomplete input data", "Tag '{}' for setting '{}' not found")
LimitationNotFound = ErrorInfo(27006, "Object not found", "Limitation named '{}' not found")
LimitationIntegrityError = ErrorInfo(27007, "Integrity error", "Limitation named '{}' already exists")
GroupNotFound = ErrorInfo(27008, "Object not found", "Group named '{}' not found")
GroupsNotFound = ErrorInfo(27009, "Object not found", "One or more groups not found, including group named '{}'")
GroupIntegrityError = ErrorInfo(27010, "Integrity error", "Group named '{}' already exists")
CannotRemoveDefaultSetting = ErrorInfo(27011, "Bad/incomplete input data", "Cannot remove default setting '{}'")
NotAllowedToChangeDefaultSettingName = ErrorInfo(
27012, "Bad/incomplete input data", "Not allowed to change default setting name"
)
[docs]class LunaTasks:
"""
Luna-tasks errors
"""
FailSendSubtasks = ErrorInfo(28000, "Network error", "Cannot send subtasks to task_workers. Reason: '{}'")
TaskNotFound = ErrorInfo(28001, "Object not found", "Task with id '{}' not found")
TasksNotFound = ErrorInfo(28002, "Object not found", "One or more tasks not found, including task with id '{}'")
TaskErrorNotFound = ErrorInfo(28003, "Object not found", "Task error with id '{}' not found")
TaskErrorsNotFound = ErrorInfo(
28004, "Object not found", "One or more task errors not found, including task error with id '{}'"
)
TasksWorkerShutdown = ErrorInfo(
28005,
"Stop tasks worker",
"On worker shutdown all active tasks on the worker are failed, all active subtasks are cancelled",
)
FailToChangeTaskStatus = ErrorInfo(
28006, "Internal server error", "Failed to update task {} status. Desired status: {}"
)
FailToChangeSubTaskStatus = ErrorInfo(
28007, "Internal server error", "Failed to update subtask {} status. Desired status: {}"
)
FailToUpdateTaskProgress = ErrorInfo(
28008, "Internal server error", "Failed to update task {} progress. Desired progress: {}"
)
AttributeIsNotEqual = ErrorInfo(
28009, "Attribute is not equal", "Event ({}) attribute is not equal {} corresponding face attribute"
)
ObjectsForClusteringNotFound = ErrorInfo(28010, "Objects not found", "Objects for clustering not found (empty set)")
FailToCreateCSVFile = ErrorInfo(28011, "Internal server error", "Failed to save report to a csv-file")
FailToCreateArchive = ErrorInfo(28012, "Internal server error", "Failed to create archive from a report")
BadTaskTypeForReport = ErrorInfo(
28013, "Bad/incomplete input data", "Tasks with type '{}' does not support a build report"
)
BadColumnForReport = ErrorInfo(28014, "Bad/incomplete input data", "Column '{}' not allowed in report by {}")
BadTaskStatus = ErrorInfo(
28015, "Bad/incomplete input data", "Tasks with status '{}' does not support a build report"
)
ClusterizationTaskWithoutResult = ErrorInfo(
28016, "Bad/incomplete input data", "Clusterization task without result does not support a build report"
)
TaskResultNotFound = ErrorInfo(28017, "Object not found", "Result of the task '{}' not found")
TaskDoesNotHaveResultYet = ErrorInfo(28018, "Object not found", "Task '{}' does not have result yet")
TaskCanNotCanceled = ErrorInfo(28019, "Bad/incomplete input data", "Task '{}' with status {} cannot be canceled")
ImpossibleGetTaskResult = ErrorInfo(28020, "Object not found", "Impossible get a result of task {} with status {}")
EventsIsNotSupported = ErrorInfo(28021, "Forbidden", "Service does not support Luna Events as source for tasks")
ObjectsForXMatchNotFound = ErrorInfo(28022, "Objects not found", "{} for cross-matching not found (empty set)")
MatchReferenceMissingUuid = ErrorInfo(28023, "Reference uuid is missing", "Reference uuid is missing: {}")
MatchReferenceNotExtractedUuid = ErrorInfo(
28024, "Reference uuid has no extracted descriptor", "Reference uuid has no extracted descriptor: {}"
)
TaksHasBeenCancelled = ErrorInfo(28025, "Task has been cancelled", "Task '{}' has been cancelled")
EstimatorArchiveReadError = ErrorInfo(28026, "Failed to read archive", "{}")
EstimatorFileReadError = ErrorInfo(28027, "Failed to read file", "{}")
EstimatorDirectoryReadError = ErrorInfo(28028, "Failed to read directory", "{}")
EstimatorNetworkDiskNotAvailable = ErrorInfo(28029, "Network disk is not available", "{}")
EstimatorFtpLoginError = ErrorInfo(28030, "FTP server authorization error", "{}")
EstimatorFtpUnreachable = ErrorInfo(28031, "FTP server is unreachable", "{}")
EstimatorFtpDownloadError = ErrorInfo(28032, "FTP download error", "{}")
EstimatorFtpListingError = ErrorInfo(28033, "FTP file listing error", "{}")
[docs]class LunaSender:
"""
Luna-sender errors
"""
AccountRequired4Subscription = ErrorInfo(
29001, "Forbidden", "Cannot subscribe for events without 'Luna-Account-Id' header set"
)
FailToSubscribe = ErrorInfo(29002, "Internal server error", "Failed to subscribe to chanel {}")
FailToProcessMessage = ErrorInfo(29003, "Internal server error", "Failed to process input message")
FailToPublishMessageToWS = ErrorInfo(29004, "Internal server error", "Failed to publish message to ws")
RedisDisconnected = ErrorInfo(29005, "Service Unavailable", "Redis disconnected")
[docs]class LunaPythonMatcher:
"""
Luna-python-matcher errors
"""
DifferentAccounts = ErrorInfo(
31000, "Bad/incomplete input data", "Account id from query parameters does not match the one from {} filters"
)
VersionNotMatchWithVersionForMatching = ErrorInfo(
31001,
"Bad/incomplete input data",
"Descriptor has the version ({}) which does not match with version ({}) which is supposed to use "
"for the matching",
)
CrossMatchLimitExceeded = ErrorInfo(
31002,
"Bad/incomplete input data",
"Cross-matching filters presume too many received objects. Current general limit - {}",
)
InternalCrossMatchError = ErrorInfo(31003, "Internal server error", "Unknown cross matching error")
DifferentVersionsNotAllowed = ErrorInfo(
31005, "Bad/incomplete input data", "Matching between different versions {} is not allowed"
)
UnexpectedMatcherError = ErrorInfo(31006, "Internal server error", "Unexpected behavior of the '{}' matcher: {}")
ReferencesLimitExceeded = ErrorInfo(
31007,
"Bad/incomplete input data",
"Amount of specified/required references exceeds limit: {}",
)
[docs]class LivenessErrors:
"""
Liveness prediction errors
https://docs.idrnd.net/face/#error-codes
"""
ServiceFailure = ErrorInfo(32000, "Internal server error", "Failed to predict liveness")
FaceTooClose = ErrorInfo(32001, "A distance between face and camera is too small", "{}")
FaceCloseToBorder = ErrorInfo(32002, "Face is too close to one or more borders.", "{}")
FaceCropped = ErrorInfo(32003, "Face is cropped", "{}")
LivenessFaceNotFound = ErrorInfo(32004, "Face detector can't find face on image", "{}")
FaceTooSmall = ErrorInfo(32005, "Facial area is not big enough for analysis.", "{}")
FaceAngleTooLarge = ErrorInfo(32006, "Facial out-of-plane rotation angle is extremely large", "{}")
FailedToPredictLandmarks = ErrorInfo(32007, "Landmarks prediction error", "{}")
FailedToPreprocessImageWhileDetect = ErrorInfo(32008, "Face detection error", "{}")
FailedToPreprocessImageWhilePredict = ErrorInfo(32009, "Liveness prediction error", "{}")
FailedToReadImage = ErrorInfo(32010, "File decoding error", "{}")
FailedToReadModel = ErrorInfo(32011, "Model deserializing error", "{}")
FailedToWriteImage = ErrorInfo(32012, "File encoding error", "{}")
InvalidConfig = ErrorInfo(32013, "Configuration file deserializing error", "{}")
InvalidFuseMode = ErrorInfo(32014, "Invalid fuse mode provided", "{}")
NoSuchObjectInBuild = ErrorInfo(32015, "Engine or backend is not supported by the build", "{}")
TooManyFaces = ErrorInfo(32017, "Too many faces detected", "{}")
[docs]class LicensesError:
"""
Luna-licenses errors
"""
FailedToCheckFeature = ErrorInfo(33001, "License problem", "Failed to check HASP License feature {}")
FailedToGetFeatureValue = ErrorInfo(33002, "License problem", "Failed to get value of HASP License feature {}")
NoValueForRequiredFeature = ErrorInfo(
33003, "License problem", "No value found for required HASP License feature {}"
)
FailedToConsumeFeature = ErrorInfo(33004, "License problem", "Failed to consume {}")
FailedToConsumeFeatureLicenseExpired = ErrorInfo(33005, "License problem", "Failed to consume {}: license expired")
[docs]class LunaHandlers:
"""
Luna-handlers errors
"""
HandlerNotFound = ErrorInfo(34000, "Object not found", "Handler with id {} not found")
NotSupportedDescriptorVersion = ErrorInfo(34001, "Forbidden", "Descriptor version {} is not supported")
CorruptHandler = ErrorInfo(34002, "Internal server error", "Cannot load handler with id '{}'. Handler is corrupted")
AggregationNotSupported = ErrorInfo(
34003, "Bad/incomplete input data", "Aggregation is not supported for raw descriptors"
)
VerifierNotFound = ErrorInfo(34004, "Object not found", "Verifier with id {} not found")
CandidatesLimitExceeded = ErrorInfo(34005, "Bad/incomplete input data", "Candidates limit exceeded: {} > {}")
NoCandidatesSpecified = ErrorInfo(34006, "Bad/incomplete input data", "No candidates specified")
HandlerMustByDynamic = ErrorInfo(34007, "Forbidden", "Allowed use only dynamic handler")
MultipleBodies = ErrorInfo(34008, "Multiple bodies found", "Multiple bodies found in image {} , detect {}")
[docs]class LunaBackport4:
"""
Luna-Backport4 errors
"""
GCAttributeNotAvailable = ErrorInfo(35000, "Bad/incomplete input data", "Attributes gc is not available")
LunaSenderIsDisabled = ErrorInfo(35001, "Forbidden", "Luna Sender service is disabled")
Backport4InvalidHandler = ErrorInfo(35002, "Handler is not supported", "Invalid handler with id '{}'")
[docs]class LunaBackport3:
"""
Luna-Backport3 errors
"""
# errors with code from platform 3
EmailExist = ErrorInfo(11011, "Unique constraint error", "An account with given email already exists")
Backport3AccountNotFound = ErrorInfo(
11002, "Authorization failed", "Account corresponding login/password not found"
)
AccountIsNotActive = ErrorInfo(11004, "Account is suspended", "Account is suspended")
TokenNotFound = ErrorInfo(11022, "Object not found", "Token not found")
BadFormatUUID = ErrorInfo(
12001,
"Bad/incomplete input data",
"Object in query is not UUID4, format: xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx",
)
NoFaces = ErrorInfo(4003, "No faces found", "No faces found.")
PersonNotFound = ErrorInfo(22007, "Object not found", "Person with id '{}' not found")
FaceAlreadyAttach = ErrorInfo(22008, "Unique constraint error", "This face is already attached to the person")
Backport3DescriptorNotFound = ErrorInfo(11018, "Object not found", "Descriptor with id '{}' not found")
ManyFaces = ErrorInfo(11012, "Extract policy error", "{}")
UnsupportedQueryParam = ErrorInfo(12018, "Bad/incomplete input data", "Unsupported param '{}'")
# errors with new error code
WrongListType = ErrorInfo(36001, "Bad/incomplete input data", "Expected list of {}. Got list of {}. List id '{}'")
BadFormatBasicAuth = ErrorInfo(
36002,
"Bad/incomplete input data",
"Bad format basic authorization header, format: Basic base64(login:password)",
)
LowThreshold = ErrorInfo(36003, "Face does not satisfy thresholds limits", "No faces found.")
FaceWasNotAttachedToPerson = ErrorInfo(36004, "Bad/incomplete input data", "Face was not linked to the person")
[docs]class ApplicationServerError:
"""
Application server error.
References:
https://sanic.readthedocs.io/en/18.12.0/sanic/api_reference.html?highlight=PayloadTooLarge#module-sanic.exceptions
"""
ResponseTimeout = ErrorInfo(37001, "Internal server error", "Service did not process the request within {} seconds")
RequestTimeout = ErrorInfo(
37002, "Request timeout", "Service did not receive the complete request message within {} seconds"
)
PayloadToLarge = ErrorInfo(37003, "Payload too large", "Request payload is too large")
UnknownWebApplicationError = ErrorInfo(37004, "Internal server error", "Unknown web application error: {}")
ClientDisconected = ErrorInfo(37005, "Client closed request", "Client closed request")
[docs]class LunaHealthCheckError:
"""
Health check error.
"""
HealthCheckError = ErrorInfo(38001, "Health check error", "{}")
[docs]class LunaStreams:
"""
Luna-streams errors
"""
StreamNotFound = ErrorInfo(39001, "Object not found", "Stream with id {} not found")
BadStreamStatus = ErrorInfo(39002, "Bad input data", "'{}' is not valid stream status; permitted: {}.")
UnableToStopProcessing = ErrorInfo(
39003,
"Unable to stop processing",
"Processing of stream with id '{}' is already in progress and cannot be stopped.",
)
BadLogTarget = ErrorInfo(39004, "Bad input data", "'{}' is not valid stream log target; permitted: {}.")
UnableToCancelProcessing = ErrorInfo(
39005, "Unable to cancel processing", "Processing of stream with id '{}' is finished and cannot be cancelled"
)
StreamGroupAlreadyExist = ErrorInfo(39006, "Unique constraint error", "Group named '{}' already exists")
StreamGroupNameNotFound = ErrorInfo(39007, "Object not found", "Group named '{}' not found")
StreamGroupNotFound = ErrorInfo(39008, "Object not found", "Group with id {} not found")
[docs]class LunaCachedMatcher:
"""
Luna-cached-matcher error
"""
ListNotInCache = ErrorInfo(40001, "Object not found", "List with id '{}' not found in the cache")
[docs]class LunaAccounts:
"""
Luna-accounts errors
"""
AccountWithLoginAlreadyExists = ErrorInfo(
41001, "Unique constraint error", "Account with login '{}' already exists"
)
AccountWithIdAlreadyExists = ErrorInfo(
41002, "Unique constraint error", "Account with account_id '{}' already exists"
)
TokenNotFoundById = ErrorInfo(41003, "Object not found", "Token with id '{}' not found")
AccountTypeChangeForbidden = ErrorInfo(
41004, "Forbidden", "Account with account_id '{}' has admin type and its type can't be changed"
)
JWTTokenNotFound = ErrorInfo(41005, "JWT token not found", "Specified JWT token doesn't exist")
AccountLoginPasswordIncorrect = ErrorInfo(
41006, "Account credentials wrong", "Account login or password are incorrect"
)
TokenExpired = ErrorInfo(41007, "Account credentials wrong", "Token has been expired")
CorruptedToken = ErrorInfo(41008, "Bad/incomplete input data", "Specified token corrupted")
IncorrectAccountTokenPermissions = ErrorInfo(
41009, "Bad/incomplete input data", "Specified permissions ('{}') are unacceptable valid for '{}' account type"
)
[docs]class LunaVLError:
"""
LunaVL errors
"""
UnknownError = ErrorInfo(99999, "Unknown fsdk core error", "{}")
BufferIsEmpty = ErrorInfo(100001, "Buffer is empty", "{}")
BufferIsNull = ErrorInfo(100002, "Buffer is null", "{}")
BufferIsFull = ErrorInfo(100003, "Buffer is full", "{}")
IncompatibleDescriptors = ErrorInfo(100004, "Descriptors are incompatible", "{}")
Internal = ErrorInfo(100005, "Internal error", "{}")
InvalidBufferSize = ErrorInfo(100006, "Invalid buffer size", "{}")
InvalidDescriptor = ErrorInfo(100007, "Invalid descriptor", "{}")
InvalidDescriptorBatch = ErrorInfo(100008, "Invalid descriptor batch", "{}")
InvalidDetection = ErrorInfo(100009, "Invalid detection", "{}")
InvalidImage = ErrorInfo(100010, "Invalid image", "{}")
InvalidImageFormat = ErrorInfo(100011, "Invalid image format", "{}")
InvalidImageSize = ErrorInfo(100012, "Invalid image size", "{}")
InvalidInput = ErrorInfo(100013, "Invalid input", "{}")
InvalidLandmarks5 = ErrorInfo(100014, "Invalid landmarks 5", "{}")
InvalidLandmarks68 = ErrorInfo(100015, "Invalid landmarks 68", "{}")
ValidationFailed = ErrorInfo(100016, "Failed validation", "{}")
InvalidSettingsProvider = ErrorInfo(100017, "Invalid settings provider", "{}")
LicenseError = ErrorInfo(100018, "Licensing issue", "{}")
ModuleNotInitialized = ErrorInfo(100019, "Module is not initialized", "{}")
ModuleNotReady = ErrorInfo(100020, "Module is not ready", "{}")
FailedToInitialize = ErrorInfo(100021, "Error during initialization fdsk image", "{}")
FailedToLoad = ErrorInfo(100022, "Error during image loadin", "{}")
FailedToSave = ErrorInfo(100023, "Error during image saving", "{}")
InvalidArchive = ErrorInfo(100024, "Archive image error", "{}")
InvalidBitmap = ErrorInfo(100025, "Invalid detection", "{}")
InvalidConversion = ErrorInfo(100026, "Image conversion not implemented", "{}")
InvalidDataPtr = ErrorInfo(100027, "Bad input image data pointer.", "{}")
InvalidDataSize = ErrorInfo(100028, "Bad input image data size", "{}")
InvalidFormat = ErrorInfo(100029, "Unsupported image format", "{}")
InvalidHeight = ErrorInfo(100030, "Invalid image height", "{}")
InvalidPath = ErrorInfo(100031, "Bad path for image saving / loading", "{}")
InvalidMemory = ErrorInfo(100032, "Error at image memory opening", "{}")
InvalidType = ErrorInfo(100033, "Unsupported image type", "{}")
InvalidWidth = ErrorInfo(100034, "Invalid image width", "{}")
BatchedInternalError = ErrorInfo(100035, "Batching error", "{}")
CreationDescriptorError = ErrorInfo(110001, "Creation descriptor error", "{}")
CreationBatchDescriptorsError = ErrorInfo(110002, "Creation descriptor error", "{}")
CreationImageError = ErrorInfo(110003, "Creation core image error", "{}")
EstimationDescriptorError = ErrorInfo(110004, "Estimation descriptor error", "{}")
EstimationBatchDescriptorError = ErrorInfo(110005, "Estimation descriptor error", "{}")
EstimationBasicAttributeError = ErrorInfo(110006, "Estimation basic attributes error", "{}")
BatchEstimationBasicAttributeError = ErrorInfo(110007, "Batch estimation basic attributes error", "{}")
EstimationAGSError = ErrorInfo(110008, "Estimation AGS error", "{}")
EstimationHeadPoseError = ErrorInfo(110009, "Estimation head pose error", "{}")
EstimationEthnisitiesError = ErrorInfo(1100010, "Estimation ethnities error", "{}")
EstimationEyesGazeError = ErrorInfo(110011, "Estimation eyes gase error", "{}")
EstimationEmotionsError = ErrorInfo(110012, "Estimation emotions error", "{}")
EstimationWarpQualityError = ErrorInfo(110013, "Estimation warp quality error", "{}")
EstimationMouthStateError = ErrorInfo(110014, "Estimation mouth state error", "{}")
EstimationEyesError = ErrorInfo(110015, "Estimation eyes error", "{}")
CreationWarpError = ErrorInfo(110016, "Creation warped image error", "{}")
WarpTransformationError = ErrorInfo(110017, "Landmarks transformation error", "{}")
DetectOneFaceError = ErrorInfo(110018, "Detect one face error", "{}")
DetectFacesError = ErrorInfo(110019, "Detect faces error", "{}")
HighMemoryUsage = ErrorInfo(110020, "High memory usage", "{}")
DetectHumanError = ErrorInfo(110021, "Detect one human body error", "{}")
DetectHumansError = ErrorInfo(110022, "Detect humans bodies error", "{}")
EstimationMaskError = ErrorInfo(110023, "Estimation mask error", "{}")
BadAggregationThreshold = ErrorInfo(110024, "Filtered aggregation error", "{}")
[docs]class RPCError:
"""
RPC errors.
"""
CommandDoesntExist = ErrorInfo(120004, "The command does not exist", "{}")
InternalServerError = ErrorInfo(120005, "Internal RPC error", "{}")
InvalidCommand = ErrorInfo(120006, "The command is not valid", "{}")
[docs]class QueueClientError:
"""
Queue client error.
"""
QueueRequestTimeout = ErrorInfo(2, "Queue request timeout", "Request timeout to routing key {}")
[docs]class AiohttpClientError:
"""
Http client error.
see https://docs.aiohttp.org/en/stable/client_reference.html#hierarchy-of-exceptions
if class changes, update errors processing in luna3/common/aiohttp_exception_map.py
"""
AiohttpInvalidURL = ErrorInfo(3, "Invalid url", "{}")
AiohttpClientPayloadError = ErrorInfo(4, "Client payload error", "{}")
AiohttpServerFingerprintMismatch = ErrorInfo(5, "Server fingerprint mismatch", "{}")
AiohttpServerSocketReadTimeoutError = ErrorInfo(6, "Socket read timeout", "Request timeout on {}, method {}")
AiohttpServerSocketConnectTimeoutError = ErrorInfo(7, "Socket connect timeout", "Request timeout on {}, method {}")
AiohttpServerConnectTimeoutError = ErrorInfo(8, "Connect timeout", "Connect timeout on {}, method {}")
AiohttpServerRequestTimeoutError = ErrorInfo(9, "Request timeout", "Request timeout on {}, method {}")
AiohttpServerDisconnectedError = ErrorInfo(10, "Server disconnected", "{}")
AiohttpServerConnectionError = ErrorInfo(11, "Server connection error", "{}")
AiohttpClientProxyConnectionError = ErrorInfo(12, "Client proxy connection error", "{}")
AiohttpClientConnectorSSLError = ErrorInfo(13, "Client connector SSL error", "{}")
AiohttpClientConnectorCertificateError = ErrorInfo(14, "Client connector certificate error", "{}")
AiohttpClientSSLError = ErrorInfo(15, "Client SSL error", "{}")
AiohttpClientConnectorError = ErrorInfo(16, "Client connector error", "{}")
AiohttpClientOSError = ErrorInfo(17, "Client OS error", "{}")
AiohttpClientConnectionError = ErrorInfo(18, "Client connection error", "{}")
AiohttpClientHttpProxyError = ErrorInfo(19, "Client HTTP proxy error", "{}")
AiohttpWSServerHandshakeError = ErrorInfo(20, "WS server handshake error", "{}")
AiohttpContentTypeError = ErrorInfo(21, "Content-Type error", "{}")
AiohttpClientResponseError = ErrorInfo(22, "Client response error", "{}")
AiohttpClientError = ErrorInfo(23, "HTTP client error", "{}")
AiohttpResponseNotJson = ErrorInfo(24, "HTTP client error", "{}")
[docs]class Error( # pylint: disable-msg=too-many-ancestors
LunaCoreError,
DataBaseError,
LunaApiError,
RESTAPIError,
LunaImageStoreError,
S3StorageError,
LocalStoreError,
ImageProcessingError,
LunaAdmin,
LunaFaces,
LunaEvents,
LIMIndexer,
LIMManager,
LIMMatcher,
IndexManagerError,
ConfiguratorError,
LunaTasks,
LunaSender,
LivenessErrors,
LicensesError,
QueueClientError,
AiohttpClientError,
LunaHandlers,
LunaPythonMatcher,
LunaVLError,
LunaBackport4,
LunaBackport3,
RPCError,
ApplicationServerError,
LunaHealthCheckError,
LunaStreams,
LunaCachedMatcher,
LunaAccounts,
):
"""
Common errors class.
"""
Success = ErrorInfo(0, "Success", "Success")
UnknownError = ErrorInfo(1, "Internal server error", "Unknown error")
[docs] @staticmethod
def getErrorByErrorCode(errorCode: int) -> ErrorInfo:
"""
Find error by error code
Args:
errorCode: error code
Returns:
Error.UnknownError if error not found.
"""
members = inspect.getmembers(Error)
for member in members:
if type(member[1]).__name__ == "ErrorInfo":
if member[1].errorCode == errorCode:
return getattr(Error, member[0])
return Error.UnknownError
[docs] @staticmethod
def generateError(error: ErrorInfo, msg: str) -> ErrorInfo:
"""
Generate error with custom details
Args:
error: error
msg: new details
Returns:
ErrorInfo(error.errorCode, error.description, msg)
"""
return ErrorInfo(error.errorCode, error.description, msg)
def _check() -> None:
"""
Check error codes' uniqueness.
"""
registeredErrorCodes = set()
for name, error in inspect.getmembers(Error, lambda err: isinstance(err, ErrorInfo)):
if error.errorCode in registeredErrorCodes:
raise RuntimeError(f"Duplicated {error.errorCode} for error '{name}'")
registeredErrorCodes.add(error.errorCode)
_check()
del _check