Skip to content

Commit

Permalink
Catch errors when reading property values in mph.inspect().
Browse files Browse the repository at this point in the history
This addresses part of the issue discussed in #68. We make
`mph.inspect()` more robust in order to diagnose those kind of
problems, but don't catch the exceptions in `Node.properties()`
as that would gloss over the upstream bug.
  • Loading branch information
john-hen committed Feb 7, 2022
1 parent 82ea32e commit 82e4c70
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions mph/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ def properties(self):
Returns names and values of all node properties as a dictionary.
In the Comsol GUI, properties are displayed in the Settings tab
of the model node.
of the model node (not to be confused with the Properties tab).
"""
java = self.java
if not hasattr(java, 'properties'):
Expand Down Expand Up @@ -967,7 +967,10 @@ def inspect(java):
print('properties:')
names = [str(name) for name in java.properties()]
for name in names:
value = get(java, name)
try:
value = get(java, name)
except Exception as error:
value = f'<{error}>'
print(f' {name}: {value}')

# Define a list of common methods to be suppressed in the output.
Expand Down

0 comments on commit 82e4c70

Please sign in to comment.