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 3 commits
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
2 changes: 1 addition & 1 deletion .python-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.10.12
3.11.0
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<a href="https://nitric.io/chat"><img alt="Discord" src="https://img.shields.io/discord/955259353043173427?label=discord&style=for-the-badge"></a>
</p>

The Python SDK supports the use of the [Nitric](https://nitric.io) framework with Python 3.10+. For more information check out the main [Nitric repo](https://github.com/nitrictech/nitric).
The Python SDK supports the use of the [Nitric](https://nitric.io) framework with Python 3.11+. For more information check out the main [Nitric repo](https://github.com/nitrictech/nitric).

Python SDKs provide an infrastructure-from-code style that lets you define resources in code. You can also write the functions that support the logic behind APIs, subscribers and schedules.

Expand Down
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 is 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