Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update nitric server connection refused errors #144

Merged
merged 4 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions nitric/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ def _create_resource(cls, resource: Type[BT], name: str, *args: Any, **kwargs: A
cls._cache[resource_type][name] = resource.make(name, *args, **kwargs) # type: ignore

return cls._cache[resource_type][name]
except ConnectionRefusedError:
except ConnectionRefusedError as cre:
raise NitricUnavailableException(
'Unable to connect to a nitric server! If you\'re running locally make sure to run "nitric start"'
) from None
"The nitric server may not be running or the host/port are inaccessible"
) from cre

@classmethod
def run(cls) -> None:
Expand All @@ -78,7 +78,7 @@ def run(cls) -> None:
except KeyboardInterrupt:

print("\nexiting")
except ConnectionRefusedError:
except ConnectionRefusedError as cre:
raise NitricUnavailableException(
'Unable to connect to a nitric server! If you\'re running locally make sure to run "nitric start"'
) from None
'If you\'re running locally use "nitric start" or "nitric run" to start your application'
) from cre
3 changes: 2 additions & 1 deletion nitric/exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ class NitricResourceException(Exception):
class NitricUnavailableException(Exception):
"""Unable to connect to a nitric server."""

pass
def __init__(self, message: str):
super().__init__("Unable to connect to nitric server." + (" " + message if message else ""))


def exception_from_grpc_error(error: GRPCError):
Expand Down
Loading