Skip to content

Commit

Permalink
Raise correct exception type. (#2912)
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxJPRey authored Apr 26, 2023
1 parent 1a2db0e commit e8d3ca4
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion pyaedt/generic/configurations.py
Original file line number Diff line number Diff line change
Expand Up @@ -1855,7 +1855,7 @@ def apply_operations_to_native_components(obj, operation_dict, native_dict): #
],
)
else: # pragma: no cover
raise "Operation not supported"
raise ValueError("Operation not supported")
if new_objs:
new_objs = list(set(new_objs) - set(old_objs))
for new_obj in new_objs:
Expand Down
1 change: 1 addition & 0 deletions pyaedt/maxwell.py
Original file line number Diff line number Diff line change
Expand Up @@ -2656,6 +2656,7 @@ def model_depth(self):

if "ModelDepth" in self.design_properties:
value_str = self.design_properties["ModelDepth"]
a = None
try:
a = float_units(value_str)
except:
Expand Down
4 changes: 2 additions & 2 deletions pyaedt/modeler/cad/Primitives.py
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ def value_in_object_units(self, value):
Parameters
----------
value : string or list of strings
value : str or list of str
One or more strings for numerical lengths. For example, ``"10mm"``
or ``["10mm", "12mm", "14mm"]``. When a list is given, the entire
list is converted.
Expand Down Expand Up @@ -562,7 +562,7 @@ def value_in_object_units(self, value):
v.rescale_to(self.model_units)
num_val = v.numeric_value
else:
raise ("Inputs to value_in_object_units must be strings or numbers.")
raise TypeError("Inputs to value_in_object_units must be strings or numbers.")

numeric_list.append(num_val)

Expand Down
8 changes: 4 additions & 4 deletions pyaedt/modeler/cad/polylines.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,8 +534,8 @@ def _point_segment_string_array(self):
break
else:
current_segment = segment_types[vertex_count]
except IndexError:
raise ("Number of segments inconsistent with the number of points!")
except Exception as e:
raise IndexError("Number of segments inconsistent with the number of points!")

if current_segment:
seg_str = self._segment_array(
Expand Down Expand Up @@ -579,7 +579,7 @@ def _evaluate_arc_angle_extra_points(self, segment, start_point):
segment.extra_points[1] contains the arc end point.
Both are function of the arc center, arc angle and arc plane.
"""
# from start-point and angle, calculate the mid- and end-points
# from start-point and angle, calculate the mid-point and end-points
# Also identify the plane of the arc ("YZ", "ZX", "XY")
plane_axes = {"YZ": [1, 2], "ZX": [2, 0], "XY": [0, 1]}
c_xyz = self._primitives.value_in_object_units(segment.arc_center)
Expand All @@ -597,7 +597,7 @@ def _evaluate_arc_angle_extra_points(self, segment, start_point):
elif c_xyz[2] == p0_xyz[2]:
plane_def = ("XY", plane_axes["XY"])
else:
raise ("Start point and arc-center do not lie on a common base plane.")
raise Exception("Start point and arc-center do not lie on a common base plane.")
segment.arc_plane = plane_def[0]

# Calculate the extra two points of the angular arc in the alpha-beta plane
Expand Down
4 changes: 2 additions & 2 deletions pyaedt/modules/SolveSetup.py
Original file line number Diff line number Diff line change
Expand Up @@ -1648,12 +1648,12 @@ def export_to_json(self, file_path, overwrite=False):
----------
file_path : str
File path of the json file.
overwrite : bool
overwrite : bool, optional
Whether to overwrite the file if it already exists.
"""
if os.path.isdir(file_path): # pragma no cover
if not overwrite: # pragma no cover
raise logging.error("File {} already exists. Configure file is not exported".format(file_path))
logging.error("File {} already exists. Configure file is not exported".format(file_path))
return self.props._export_properties_to_json(file_path)


Expand Down

0 comments on commit e8d3ca4

Please sign in to comment.