1#
2#
3# This file is part of gunicorn released under the MIT license.
4# See the LICENSE for more information.
5#
6# Vendored and modified for Plain.
7
8# We don't need to call super() in __init__ methods of our
9# BaseException and Exception classes because we also define
10# our own __str__ methods so there is no need to pass 'message'
11# to the base class to get a meaningful output from 'str(exc)'.
12# pylint: disable=super-init-not-called
13
14
15# Exit codes used by workers to communicate failure reason to the arbiter.
16WORKER_BOOT_ERROR = 3
17APP_LOAD_ERROR = 4
18
19
20# we inherit from BaseException here to make sure to not be caught
21# at application level
22class HaltServer(BaseException):
23 def __init__(self, reason: str, exit_status: int = 1) -> None:
24 self.reason = reason
25 self.exit_status = exit_status
26
27 def __str__(self) -> str:
28 return f"<HaltServer {self.reason!r} {self.exit_status}>"
29
30
31class ConfigError(Exception):
32 """Exception raised on config error"""
33
34
35class AppImportError(Exception):
36 """Exception raised when loading an application"""