Skip to content

Commit

Permalink
@GitHK review: unify exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
sanderegg committed Jun 30, 2022
1 parent e7124b3 commit d6c2bed
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions services/storage/src/simcore_service_storage/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,41 +1,50 @@
from pydantic.errors import PydanticErrorMixin


class FileMetaDataNotFoundError(PydanticErrorMixin, RuntimeError):
class StorageRuntimeError(PydanticErrorMixin, RuntimeError):
...


class DatabaseAccessError(StorageRuntimeError):
code = "database.access_error"
msg_template: str = "Unexpected error while accessing database backend"


class FileMetaDataNotFoundError(DatabaseAccessError):
code = "filemetadata.not_found_error"
msg_template: str = "The file meta data for {file_id} was not found"


class FileAccessRightError(PydanticErrorMixin, RuntimeError):
class FileAccessRightError(DatabaseAccessError):
code = "file.access_right_error"
msg_template: str = "Insufficient access rights to {access_right} {file_id}"


class ProjectAccessRightError(PydanticErrorMixin, RuntimeError):
class ProjectAccessRightError(DatabaseAccessError):
code = "file.access_right_error"
msg_template: str = "Insufficient access rights to {access_right} {project_id}"


class ProjectNotFoundError(PydanticErrorMixin, RuntimeError):
class ProjectNotFoundError(DatabaseAccessError):
code = "project.not_found_error"
msg_template: str = "Project {project_id} was not found"


class LinkAlreadyExistsError(PydanticErrorMixin, RuntimeError):
class LinkAlreadyExistsError(DatabaseAccessError):
code = "link.already_exists_error"
msg_template: str = "The link {file_id} already exists"


class S3AccessError(PydanticErrorMixin, RuntimeError):
class S3AccessError(StorageRuntimeError):
code = "s3_access.error"
msg_template: str = "Unexpected error while accessing S3 backend"


class S3BucketInvalidError(PydanticErrorMixin, RuntimeError):
class S3BucketInvalidError(S3AccessError):
code = "s3_bucket.invalid_error"
msg_template: str = "The {bucket} is invalid"


class S3KeyNotFoundError(PydanticErrorMixin, RuntimeError):
class S3KeyNotFoundError(S3AccessError):
code = "s3_key.not_found_error"
msg_template: str = "The file {key} in {bucket} was not found"

0 comments on commit d6c2bed

Please sign in to comment.