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

Higher-level exceptions #3634

Open
seanpearsonuk opened this issue Jan 10, 2025 · 0 comments
Open

Higher-level exceptions #3634

seanpearsonuk opened this issue Jan 10, 2025 · 0 comments
Assignees

Comments

@seanpearsonuk
Copy link
Collaborator

Investigate PyFluent behaviour to find scenarios where we could catch and rethrow to provide improved error information to users. See this post: https://softwareengineering.stackexchange.com/a/231059.

Note some usage examples where the first example could reraise an exception closer to the user's context:

>>> pf.connect_to_fluent(ip="1.2.3.4",  port=5555)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\ANSYSDev\pyfluent\src\ansys\fluent\core\launcher\launcher.py", line 349, in connect_to_fluent
    fluent_connection = FluentConnection(
  File "C:\ANSYSDev\pyfluent\src\ansys\fluent\core\fluent_connection.py", line 417, in __init__
    self.health_check.check_health()
  File "C:\ANSYSDev\pyfluent\src\ansys\fluent\core\services\health_check.py", line 62, in check_health
    response = self._stub.Check(request, metadata=self._metadata)
  File "C:\ANSYSDev\pyfluent\.env-local-2\lib\site-packages\grpc\_interceptor.py", line 277, in __call__
    response, ignored_call = self._with_call(
  File "C:\ANSYSDev\pyfluent\.env-local-2\lib\site-packages\grpc\_interceptor.py", line 329, in _with_call
    call = self._interceptor.intercept_unary_unary(
  File "C:\ANSYSDev\pyfluent\src\ansys\fluent\core\services\interceptors.py", line 124, in intercept_unary_unary
    return self._intercept_call(continuation, client_call_details, request)
  File "C:\ANSYSDev\pyfluent\src\ansys\fluent\core\services\interceptors.py", line 114, in _intercept_call
    raise new_ex from None
RuntimeError: failed to connect to all addresses; last error: UNKNOWN: ipv4:1.2.3.4:5555: tcp handshaker shutdown
>>>
>>> pf.connect_to_fluent(ip="1.2.3.4")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\ANSYSDev\pyfluent\src\ansys\fluent\core\launcher\launcher.py", line 348, in connect_to_fluent
    ip, port, password = _get_server_info(server_info_file_name, ip, port, password)
  File "C:\ANSYSDev\pyfluent\src\ansys\fluent\core\launcher\server_info.py", line 56, in _get_server_info
    raise IpPortNotProvided()
ansys.fluent.core.launcher.error_handler.IpPortNotProvided: Provide either 'ip' and 'port' or 'server_info_file_name'.
>>>
>>> pf.connect_to_fluent(port=3333)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\ANSYSDev\pyfluent\src\ansys\fluent\core\launcher\launcher.py", line 348, in connect_to_fluent
    ip, port, password = _get_server_info(server_info_file_name, ip, port, password)
  File "C:\ANSYSDev\pyfluent\src\ansys\fluent\core\launcher\server_info.py", line 56, in _get_server_info
    raise IpPortNotProvided()
ansys.fluent.core.launcher.error_handler.IpPortNotProvided: Provide either 'ip' and 'port' or 'server_info_file_name'.
>>>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 2025 Q1 Jan - Mar
Development

No branches or pull requests

2 participants