Skip to content

Commit 523563e

Browse files
committed
Unnest the exceptions package
1 parent 54b0b98 commit 523563e

File tree

11 files changed

+83
-83
lines changed

11 files changed

+83
-83
lines changed

cs3client/auth.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from cs3.rpc.v1beta1.code_pb2 import CODE_OK
1818

1919
from .cs3client import CS3Client
20-
from .exceptions.exceptions import AuthenticationException, SecretNotSetException
20+
from .exceptions import AuthenticationException, SecretNotSetException
2121
from .config import Config
2222

2323

cs3client/exceptions/__init__.py

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
"""
2+
exceptions
3+
4+
Custom exception classes for the CS3 client.
5+
Where applicable, the default values correspond to the Linux standard error strings.
6+
7+
Authors: Rasmus Welander, Diogo Castro, Giuseppe Lo Presti.
8+
9+
Last updated: 01/08/2024
10+
"""
11+
12+
13+
class AuthenticationException(Exception):
14+
"""
15+
Standard error thrown when attempting an operation without the required access rights
16+
"""
17+
18+
def __init__(self, message: str = "Operation not permitted"):
19+
super().__init__(message)
20+
21+
22+
class NotFoundException(IOError):
23+
"""
24+
Standard file missing message
25+
"""
26+
27+
def __init__(self, message: str = "No such file or directory"):
28+
super().__init__(message)
29+
30+
31+
class SecretNotSetException(Exception):
32+
"""
33+
Standard file missing message
34+
"""
35+
36+
def __init__(self, message: str = "Secret was not set, unable to authenticate"):
37+
super().__init__(message)
38+
39+
40+
class FileLockedException(IOError):
41+
"""
42+
Standard error thrown when attempting to overwrite a file/xattr with a mistmatched lock,
43+
or when a lock operation cannot be performed because of failed preconditions
44+
"""
45+
46+
def __init__(self, message: str = "Lock mismatch"):
47+
super().__init__(message)
48+
49+
50+
class UnknownException(Exception):
51+
"""
52+
Standard exception to be thrown when we get an error that is unknown, e.g. not defined in the cs3api
53+
"""
54+
55+
def __init__(self, message: str = ""):
56+
super().__init__(message)
57+
58+
59+
class AlreadyExistsException(IOError):
60+
"""
61+
Standard error thrown when attempting to create a resource that already exists
62+
"""
63+
64+
def __init__(self, message: str = "File exists"):
65+
super().__init__(message)
66+
67+
68+
class UnimplementedException(Exception):
69+
"""
70+
Standard error thrown when attempting to use a feature that is not implemented
71+
"""
72+
73+
def __init__(self, message: str = "Not implemented"):
74+
super().__init__(message)

cs3client/exceptions/exceptions.py

Lines changed: 0 additions & 74 deletions
This file was deleted.

cs3client/file.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121

2222
from .config import Config
23-
from .exceptions.exceptions import AuthenticationException, FileLockedException
23+
from .exceptions import AuthenticationException, FileLockedException
2424
from .cs3resource import Resource
2525
from .statuscodehandler import StatusCodeHandler
2626

cs3client/statuscodehandler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import cs3.rpc.v1beta1.code_pb2 as cs3code
1111
import cs3.rpc.v1beta1.status_pb2 as cs3status
1212

13-
from .exceptions.exceptions import AuthenticationException, NotFoundException, \
13+
from .exceptions import AuthenticationException, NotFoundException, \
1414
UnknownException, AlreadyExistsException, FileLockedException, UnimplementedException
1515
from .config import Config
1616

docs/source/exceptions.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
exceptions Module
22
=================
33

4-
.. automodule:: exceptions.exceptions
4+
.. automodule:: exceptions
55
:members:
66
:undoc-members:
77
:show-inheritance:

tests/test_app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from unittest.mock import Mock, patch
1313
import pytest
1414

15-
from cs3client.exceptions.exceptions import (
15+
from cs3client.exceptions import (
1616
AuthenticationException,
1717
NotFoundException,
1818
UnknownException,

tests/test_checkpoint.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import pytest
1313
import cs3.rpc.v1beta1.code_pb2 as cs3code
1414

15-
from cs3client.exceptions.exceptions import (
15+
from cs3client.exceptions import (
1616
AuthenticationException,
1717
NotFoundException,
1818
UnknownException,

tests/test_file.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import cs3.rpc.v1beta1.code_pb2 as cs3code
1414

1515
from cs3client.cs3resource import Resource
16-
from cs3client.exceptions.exceptions import (
16+
from cs3client.exceptions import (
1717
AuthenticationException,
1818
NotFoundException,
1919
FileLockedException,

tests/test_share.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import cs3.storage.provider.v1beta1.resources_pb2 as cs3spr
1616
import cs3.rpc.v1beta1.code_pb2 as cs3code
1717

18-
from cs3client.exceptions.exceptions import (
18+
from cs3client.exceptions import (
1919
AuthenticationException,
2020
NotFoundException,
2121
UnknownException,

tests/test_user.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from unittest.mock import Mock, patch
1313
import cs3.rpc.v1beta1.code_pb2 as cs3code
1414

15-
from cs3client.exceptions.exceptions import (
15+
from cs3client.exceptions import (
1616
AuthenticationException,
1717
NotFoundException,
1818
UnknownException,

0 commit comments

Comments
 (0)