2022-09-20 20:09:21 +03:00
|
|
|
"""Exception classes"""
|
2022-07-01 14:28:39 +04:00
|
|
|
|
2022-07-01 10:31:23 +04:00
|
|
|
from typing import Final
|
|
|
|
|
|
|
|
|
2021-10-08 19:35:20 +04:00
|
|
|
class AternosError(Exception):
|
2022-06-16 15:40:10 +04:00
|
|
|
|
2022-06-23 15:13:56 +04:00
|
|
|
"""Common error class"""
|
|
|
|
|
2021-10-08 19:35:20 +04:00
|
|
|
|
2022-04-28 09:23:02 +04:00
|
|
|
class CloudflareError(AternosError):
|
2022-06-23 15:13:56 +04:00
|
|
|
|
|
|
|
"""Raised when the parser is unable
|
|
|
|
to bypass Cloudflare protection"""
|
|
|
|
|
2022-04-28 09:23:02 +04:00
|
|
|
|
2022-03-18 18:38:36 +04:00
|
|
|
class CredentialsError(AternosError):
|
2022-06-23 15:13:56 +04:00
|
|
|
|
|
|
|
"""Raised when a session cookie is empty
|
|
|
|
which means incorrect credentials"""
|
|
|
|
|
2022-06-16 15:40:10 +04:00
|
|
|
|
2022-09-23 17:21:17 +04:00
|
|
|
class TwoFactorAuthError(CredentialsError):
|
|
|
|
|
|
|
|
"""Raised if 2FA is enabled,
|
|
|
|
but code was not passed to a login function"""
|
|
|
|
|
|
|
|
|
2022-06-16 15:40:10 +04:00
|
|
|
class TokenError(AternosError):
|
2022-06-23 15:13:56 +04:00
|
|
|
|
|
|
|
"""Raised when the parser is unable
|
|
|
|
to extract Aternos ajax token"""
|
|
|
|
|
2021-10-08 19:35:20 +04:00
|
|
|
|
2022-03-18 18:38:36 +04:00
|
|
|
class ServerError(AternosError):
|
2022-06-23 15:13:56 +04:00
|
|
|
|
MkDocs, Readme, Files API, Automated session saving, v2.0.1
MkDocs: sphinx docstrings rewritten to google, improved config, written the major part of how-to.
Readme: centered title + logo, added badges, features list, updated changelog.
Improved Files API, added automatical session saving and restoring to Client.
Some changes in makefile and gitignore.
License Notice now refers to all contributors.
2022-08-26 16:14:07 +04:00
|
|
|
"""Common class for server errors"""
|
2022-06-23 15:13:56 +04:00
|
|
|
|
2022-07-01 10:31:23 +04:00
|
|
|
def __init__(self, reason: str, message: str = '') -> None:
|
MkDocs, Readme, Files API, Automated session saving, v2.0.1
MkDocs: sphinx docstrings rewritten to google, improved config, written the major part of how-to.
Readme: centered title + logo, added badges, features list, updated changelog.
Improved Files API, added automatical session saving and restoring to Client.
Some changes in makefile and gitignore.
License Notice now refers to all contributors.
2022-08-26 16:14:07 +04:00
|
|
|
"""Common class for server errors
|
|
|
|
|
|
|
|
Args:
|
|
|
|
reason (str): Code which contains error reason
|
|
|
|
message (str, optional): Error message
|
|
|
|
"""
|
|
|
|
|
2022-07-01 10:31:23 +04:00
|
|
|
self.reason = reason
|
|
|
|
super().__init__(message)
|
2022-06-16 15:40:10 +04:00
|
|
|
|
2022-06-23 15:13:56 +04:00
|
|
|
|
2022-07-01 10:31:23 +04:00
|
|
|
class ServerStartError(AternosError):
|
2022-06-16 15:40:10 +04:00
|
|
|
|
MkDocs, Readme, Files API, Automated session saving, v2.0.1
MkDocs: sphinx docstrings rewritten to google, improved config, written the major part of how-to.
Readme: centered title + logo, added badges, features list, updated changelog.
Improved Files API, added automatical session saving and restoring to Client.
Some changes in makefile and gitignore.
License Notice now refers to all contributors.
2022-08-26 16:14:07 +04:00
|
|
|
"""Raised when Aternos can not start Minecraft server"""
|
2022-06-23 15:13:56 +04:00
|
|
|
|
2022-07-01 10:31:23 +04:00
|
|
|
MESSAGE: Final = 'Unable to start server, code: {}'
|
|
|
|
reason_msg = {
|
2022-06-16 15:40:10 +04:00
|
|
|
|
2022-07-01 10:31:23 +04:00
|
|
|
'eula':
|
|
|
|
'EULA was not accepted. '
|
|
|
|
'Use start(accepteula=True)',
|
2022-06-16 15:40:10 +04:00
|
|
|
|
MkDocs, Readme, Files API, Automated session saving, v2.0.1
MkDocs: sphinx docstrings rewritten to google, improved config, written the major part of how-to.
Readme: centered title + logo, added badges, features list, updated changelog.
Improved Files API, added automatical session saving and restoring to Client.
Some changes in makefile and gitignore.
License Notice now refers to all contributors.
2022-08-26 16:14:07 +04:00
|
|
|
'already': 'Server has already started',
|
2022-07-01 10:31:23 +04:00
|
|
|
'wrongversion': 'Incorrect software version installed',
|
2022-06-23 15:13:56 +04:00
|
|
|
|
2022-07-01 10:31:23 +04:00
|
|
|
'file':
|
|
|
|
'File server is unavailbale, '
|
|
|
|
'view https://status.aternos.gmbh',
|
2022-06-16 15:40:10 +04:00
|
|
|
|
MkDocs, Readme, Files API, Automated session saving, v2.0.1
MkDocs: sphinx docstrings rewritten to google, improved config, written the major part of how-to.
Readme: centered title + logo, added badges, features list, updated changelog.
Improved Files API, added automatical session saving and restoring to Client.
Some changes in makefile and gitignore.
License Notice now refers to all contributors.
2022-08-26 16:14:07 +04:00
|
|
|
'size': 'Available storage size limit (4 GB) has been reached'
|
2022-07-01 10:31:23 +04:00
|
|
|
}
|
2022-06-16 15:40:10 +04:00
|
|
|
|
2022-07-01 10:31:23 +04:00
|
|
|
def __init__(self, reason: str) -> None:
|
MkDocs, Readme, Files API, Automated session saving, v2.0.1
MkDocs: sphinx docstrings rewritten to google, improved config, written the major part of how-to.
Readme: centered title + logo, added badges, features list, updated changelog.
Improved Files API, added automatical session saving and restoring to Client.
Some changes in makefile and gitignore.
License Notice now refers to all contributors.
2022-08-26 16:14:07 +04:00
|
|
|
"""Raised when Aternos
|
|
|
|
can not start Minecraft server
|
|
|
|
|
|
|
|
Args:
|
|
|
|
reason (str):
|
|
|
|
Code which contains error reason
|
|
|
|
"""
|
|
|
|
|
2022-07-01 10:31:23 +04:00
|
|
|
super().__init__(
|
|
|
|
reason,
|
|
|
|
self.reason_msg.get(
|
MkDocs, Readme, Files API, Automated session saving, v2.0.1
MkDocs: sphinx docstrings rewritten to google, improved config, written the major part of how-to.
Readme: centered title + logo, added badges, features list, updated changelog.
Improved Files API, added automatical session saving and restoring to Client.
Some changes in makefile and gitignore.
License Notice now refers to all contributors.
2022-08-26 16:14:07 +04:00
|
|
|
reason,
|
|
|
|
self.MESSAGE.format(reason)
|
2022-07-01 10:31:23 +04:00
|
|
|
)
|
|
|
|
)
|
2022-06-23 15:13:56 +04:00
|
|
|
|
2021-10-15 15:12:45 +04:00
|
|
|
|
2022-03-18 18:38:36 +04:00
|
|
|
class FileError(AternosError):
|
2022-06-23 15:13:56 +04:00
|
|
|
|
|
|
|
"""Raised when trying to execute a disallowed
|
|
|
|
by Aternos file operation"""
|
2022-07-01 03:47:19 +02:00
|
|
|
|
2022-07-01 10:31:23 +04:00
|
|
|
|
2022-07-01 14:28:39 +04:00
|
|
|
# PermissionError is a built-in,
|
|
|
|
# so this exception called AternosPermissionError
|
|
|
|
class AternosPermissionError(AternosError):
|
2022-07-01 10:31:23 +04:00
|
|
|
|
|
|
|
"""Raised when trying to execute a disallowed command,
|
|
|
|
usually because of shared access rights"""
|