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

Cleaner error handling #1935

Merged
merged 4 commits into from
Mar 23, 2023
Merged

Conversation

germa89
Copy link
Collaborator

@germa89 germa89 commented Mar 23, 2023

Improving error handling of non-available results.

Now, if you request a non-available data, something like this will show:

>>> nl_plwk = mapdl.post_processing.nodal_values('NL','PLWK')
CRITICAL - pymapdl_global -  logging - handle_exception - Uncaught exception
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/german.ayuso/pymapdl/.venv_macos/lib/python3.11/site-packages/ansys/mapdl/core/post.py", line 313, in nodal_values
    values = self._ndof_rst(item=item, it1num=comp)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/german.ayuso/pymapdl/.venv_macos/lib/python3.11/site-packages/ansys/mapdl/core/post.py", line 36, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/german.ayuso/pymapdl/.venv_macos/lib/python3.11/site-packages/ansys/mapdl/core/post.py", line 768, in _ndof_rst
    raise ValueError(f"The results obtained with '{item},{it1num},{item2}' are empty.\n"
ValueError: The results obtained with 'NL,PLWK,' are empty.
You can check the MAPDL output by issuing:

mapdl.run('*vget,temp_array, node, , NL, PLWK, ')

And if you follow the message and issue mapdl.run('*vget,temp_array, node, , NL, PLWK, '), you obtain:

>>> mapdl.run('*vget,temp_array, node, , NL, PLWK, ')
CRITICAL - pymapdl_global -  logging - handle_exception - Uncaught exception
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/german.ayuso/pymapdl/.venv_macos/lib/python3.11/site-packages/ansys/mapdl/core/mapdl.py", line 2907, in run
    self._raise_errors(text)
  File "/Users/german.ayuso/pymapdl/.venv_macos/lib/python3.11/site-packages/ansys/mapdl/core/mapdl.py", line 3850, in _raise_errors
    raise MapdlCommandIgnoredError(text)
ansys.mapdl.core.errors.MapdlCommandIgnoredError: VECTOR GET OPERATION  temp_array  VECTOR LENGTH=   22612
 NAME= NODE         0  NL    PLWK

 *** WARNING ***                         CP =       9.312   TIME= 04:34:42
 The requested NL data is not available.  The *VGET command is ignored.

Ignore these messages by setting 'ignore_errors'=True

Close #1275

@germa89 germa89 self-assigned this Mar 23, 2023
@germa89 germa89 added the Enhancement Improve any current implemented feature label Mar 23, 2023
@germa89 germa89 requested review from a team and clatapie and removed request for a team March 23, 2023 04:40
@codecov
Copy link

codecov bot commented Mar 23, 2023

Codecov Report

Merging #1935 (ba7ec72) into main (d21760a) will increase coverage by 7.93%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #1935      +/-   ##
==========================================
+ Coverage   78.07%   86.00%   +7.93%     
==========================================
  Files          44       44              
  Lines        7878     7877       -1     
==========================================
+ Hits         6151     6775     +624     
+ Misses       1727     1102     -625     

src/ansys/mapdl/core/post.py Outdated Show resolved Hide resolved
src/ansys/mapdl/core/post.py Outdated Show resolved Hide resolved
Copy link
Contributor

@clatapie clatapie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@germa89 germa89 merged commit 4b7ceb2 into main Mar 23, 2023
@germa89 germa89 deleted the feat/improving-error-handlenging-of-empty-results branch March 23, 2023 10:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Improve any current implemented feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug located in post1 processor
2 participants