Source code for vso_api_client.exceptions
"""
VSO API Client: Client for the Volcano Space Observatory API
Copyright (C) CNES, CNRS, Université de Lille, Région Hauts-de-France
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
[docs]
class APIError(Exception):
"""Base exception for all VSO API errors.
This exception is raised for general API errors that don't fit into
more specific error categories.
:param status_code: HTTP status code returned by the API.
:param message: Error message describing the issue.
"""
def __init__(self, status_code: int, message: str) -> None:
super().__init__()
self.message = message
self.status_code = status_code
def __str__(self):
return self.message
[docs]
class AuthenticationError(APIError):
"""Exception raised for authentication errors (HTTP 401/403).
This exception is raised when the API returns a 401 or 403 status code,
indicating authentication or authorization failures.
"""
pass
[docs]
class ServiceUnavailableError(APIError):
"""Exception raised when the service is unavailable (HTTP 503).
This exception is raised when the API returns a 503 status code,
indicating that the service is temporarily unavailable.
"""
pass
[docs]
class InternalServerError(APIError):
"""Exception raised for internal server errors (HTTP 500).
This exception is raised when the API returns a 500 status code,
indicating an unexpected server-side error.
"""
pass
[docs]
class NotFoundError(APIError):
"""Exception raised when a resource is not found (HTTP 404).
This exception is raised when the API returns a 404 status code,
indicating that the requested resource does not exist.
"""
pass