Skip to content

Commit

Permalink
Unnest the exceptions package
Browse files Browse the repository at this point in the history
  • Loading branch information
glpatcern committed Sep 13, 2024
1 parent 63ed8be commit f8f393c
Show file tree
Hide file tree
Showing 11 changed files with 83 additions and 83 deletions.
2 changes: 1 addition & 1 deletion cs3client/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from cs3.rpc.v1beta1.code_pb2 import CODE_OK

from .cs3client import CS3Client
from .exceptions.exceptions import AuthenticationException, SecretNotSetException
from .exceptions import AuthenticationException, SecretNotSetException
from .config import Config


Expand Down
74 changes: 74 additions & 0 deletions cs3client/exceptions/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
"""
exceptions
Custom exception classes for the CS3 client.
Where applicable, the default values correspond to the Linux standard error strings.
Authors: Rasmus Welander, Diogo Castro, Giuseppe Lo Presti.
Emails: [email protected], [email protected], [email protected]
Last updated: 01/08/2024
"""


class AuthenticationException(Exception):
"""
Standard error thrown when attempting an operation without the required access rights
"""

def __init__(self, message: str = "Operation not permitted"):
super().__init__(message)


class NotFoundException(IOError):
"""
Standard file missing message
"""

def __init__(self, message: str = "No such file or directory"):
super().__init__(message)


class SecretNotSetException(Exception):
"""
Standard file missing message
"""

def __init__(self, message: str = "Secret was not set, unable to authenticate"):
super().__init__(message)


class FileLockedException(IOError):
"""
Standard error thrown when attempting to overwrite a file/xattr with a mistmatched lock,
or when a lock operation cannot be performed because of failed preconditions
"""

def __init__(self, message: str = "Lock mismatch"):
super().__init__(message)


class UnknownException(Exception):
"""
Standard exception to be thrown when we get an error that is unknown, e.g. not defined in the cs3api
"""

def __init__(self, message: str = ""):
super().__init__(message)


class AlreadyExistsException(IOError):
"""
Standard error thrown when attempting to create a resource that already exists
"""

def __init__(self, message: str = "File exists"):
super().__init__(message)


class UnimplementedException(Exception):
"""
Standard error thrown when attempting to use a feature that is not implemented
"""

def __init__(self, message: str = "Not implemented"):
super().__init__(message)
74 changes: 0 additions & 74 deletions cs3client/exceptions/exceptions.py

This file was deleted.

2 changes: 1 addition & 1 deletion cs3client/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@


from .config import Config
from .exceptions.exceptions import AuthenticationException, FileLockedException
from .exceptions import AuthenticationException, FileLockedException
from .cs3resource import Resource
from .statuscodehandler import StatusCodeHandler

Expand Down
2 changes: 1 addition & 1 deletion cs3client/statuscodehandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import cs3.rpc.v1beta1.code_pb2 as cs3code
import cs3.rpc.v1beta1.status_pb2 as cs3status

from .exceptions.exceptions import AuthenticationException, NotFoundException, \
from .exceptions import AuthenticationException, NotFoundException, \
UnknownException, AlreadyExistsException, FileLockedException, UnimplementedException
from .config import Config

Expand Down
2 changes: 1 addition & 1 deletion docs/source/exceptions.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
exceptions Module
=================

.. automodule:: exceptions.exceptions
.. automodule:: exceptions
:members:
:undoc-members:
:show-inheritance:
2 changes: 1 addition & 1 deletion tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from unittest.mock import Mock, patch
import pytest

from cs3client.exceptions.exceptions import (
from cs3client.exceptions import (
AuthenticationException,
NotFoundException,
UnknownException,
Expand Down
2 changes: 1 addition & 1 deletion tests/test_checkpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import pytest
import cs3.rpc.v1beta1.code_pb2 as cs3code

from cs3client.exceptions.exceptions import (
from cs3client.exceptions import (
AuthenticationException,
NotFoundException,
UnknownException,
Expand Down
2 changes: 1 addition & 1 deletion tests/test_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import cs3.rpc.v1beta1.code_pb2 as cs3code

from cs3client.cs3resource import Resource
from cs3client.exceptions.exceptions import (
from cs3client.exceptions import (
AuthenticationException,
NotFoundException,
FileLockedException,
Expand Down
2 changes: 1 addition & 1 deletion tests/test_share.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import cs3.storage.provider.v1beta1.resources_pb2 as cs3spr
import cs3.rpc.v1beta1.code_pb2 as cs3code

from cs3client.exceptions.exceptions import (
from cs3client.exceptions import (
AuthenticationException,
NotFoundException,
UnknownException,
Expand Down
2 changes: 1 addition & 1 deletion tests/test_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from unittest.mock import Mock, patch
import cs3.rpc.v1beta1.code_pb2 as cs3code

from cs3client.exceptions.exceptions import (
from cs3client.exceptions import (
AuthenticationException,
NotFoundException,
UnknownException,
Expand Down

0 comments on commit f8f393c

Please sign in to comment.