Skip to content

Commit 4293c93

Browse files
committed
Yandex: Handling an access rights error
1 parent 9008b2d commit 4293c93

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

fcloud/drivers/yandex/errors.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from textwrap import dedent
2+
13
from ...exceptions.exceptions import DriverException
24
from ...exceptions.driver_errors import DriverError
35

@@ -23,6 +25,14 @@ class YandexError(DriverError):
2325
"""The token has expired or the token doesn't exist.""",
2426
)
2527

28+
access_denied = (
29+
"Access denied",
30+
dedent("""\
31+
Access denied. The application probably does not have sufficient
32+
permissions to perform this action. You can change the application
33+
settings on this page: https://oauth.yandex.ru/."""),
34+
)
35+
2636

2737
class YandexException(DriverException):
2838
pass

fcloud/drivers/yandex/yandex.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from yadisk.exceptions import RequestTimeoutError
1010
from yadisk.exceptions import PathNotFoundError
1111
from yadisk.exceptions import UnauthorizedError
12+
from yadisk.exceptions import ForbiddenError
1213

1314
from .errors import YandexException
1415
from .errors import YandexError
@@ -40,6 +41,8 @@ def inner(*args, **kwargs):
4041
raise YandexException(*YandexError.path_not_found_error)
4142
except UnauthorizedError:
4243
raise YandexException(*YandexError.invalid_token_error)
44+
except ForbiddenError:
45+
raise YandexException(*YandexError.access_denied)
4346
except FileNotFoundError:
4447
raise YandexException(*FileError.not_exists_error)
4548
except PermissionError:

0 commit comments

Comments
 (0)