Better Error message if no backend installed #1042 (#1045)

* Better Error message if no backend installed #1042

* change the error message as requested

* Update src/py/reactpy/reactpy/backend/default.py

Co-authored-by: Ryan Morshead <ryan.morshead@gmail.com>

* fix linting issues

* Update src/py/reactpy/reactpy/backend/default.py

Co-authored-by: Ryan Morshead <ryan.morshead@gmail.com>

* Improve readability

* Update src/py/reactpy/reactpy/backend/default.py

* make text bold

---------

Co-authored-by: Ryan Morshead <ryan.morshead@gmail.com>
This commit is contained in:
Abhiram 2023-06-13 21:39:39 +05:30 committed by GitHub
parent f559e230dc
commit 8120ddc228
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -6,7 +6,7 @@ from sys import exc_info
from typing import Any, NoReturn
from reactpy.backend.types import BackendImplementation
from reactpy.backend.utils import all_implementations
from reactpy.backend.utils import SUPPORTED_PACKAGES, all_implementations
from reactpy.types import RootComponentConstructor
logger = getLogger(__name__)
@ -59,7 +59,13 @@ def _default_implementation() -> BackendImplementation[Any]:
implementation = next(all_implementations())
except StopIteration: # nocov
logger.debug("Backend implementation import failed", exc_info=exc_info())
msg = "No built-in server implementation installed."
supported_backends = ", ".join(SUPPORTED_PACKAGES)
msg = (
"It seems you haven't installed a backend. To resolve this issue, "
"you can install a backend by running:\n\n"
'\033[1mpip install "reactpy[starlette]"\033[0m\n\n'
f"Other supported backends include: {supported_backends}."
)
raise RuntimeError(msg) from None
else:
_DEFAULT_IMPLEMENTATION = implementation