delarte/src/delarte/error.py
Barbagus 81913a6f24 Cleanup package API #20
Move all error definitions to `error` module
In `__init__`
  - Remove imports from global scope
  - Import all from `model` module
  - Import all from `error` module
Refactor: `fetch_sources()` to take the URL as argument
Coding style: import definitions from `error` and `model`
2023-01-08 20:04:18 +01:00

41 lines
970 B
Python

# License: GNU AGPL v3: http://www.gnu.org/licenses/
# This file is part of `delarte` (https://git.afpy.org/fcode/delarte.git)
"""Provide common utilities."""
class ModuleError(Exception):
"""Module error."""
def __str__(self):
"""Use the class definition docstring as a string representation."""
return self.__doc__
def __repr__(self):
"""Use the class qualified name and constructor arguments."""
return f"{self.__class__}{self.args!r}"
class UnexpectedError(ModuleError):
"""An error to report to developers."""
class InvalidUrl(ModuleError):
"""Invalid ArteTV URL."""
class UnexpectedAPIResponse(UnexpectedError):
"""Unexpected response from ArteTV."""
class UnexpectedHLSResponse(UnexpectedError):
"""Unexpected response from ArteTV."""
class UnsupportedHLSProtocol(ModuleError):
"""Program type not supported."""
class WebVTTError(UnexpectedError):
"""Unexpected WebVTT data."""