Skip to content

Commit c5222a0

Browse files
authored
Lifestyle: remove retrieving units for validation in unit tests, fix error classes (#127)
1 parent e6a7fca commit c5222a0

File tree

7 files changed

+831
-873
lines changed

7 files changed

+831
-873
lines changed

src/ansys/sherlock/core/errors.py

Lines changed: 47 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ def __init__(self, message=None, error_array=None):
288288
def str_itr(self):
289289
"""Create list of error messages."""
290290
if self.message is None:
291-
return [f"Create life phase error: {error}" for error in self.error_array]
291+
return [f"Add harmonic event error: {error}" for error in self.error_array]
292292

293293
assert self.error_array is None
294294
return [f"Add harmonic event error: {self.message}"]
@@ -348,25 +348,35 @@ def str_itr(self):
348348
class SherlockLoadRandomVibeProfileError(Exception):
349349
"""Contains the error raised when loading random vibe properties."""
350350

351-
def __init__(self, message):
352-
"""Initialize Error Message."""
351+
def __init__(self, message=None, error_array=None):
352+
"""Initialize error message."""
353353
self.message = message
354+
self.error_array = error_array
354355

355-
def __str__(self):
356-
"""Format error message."""
357-
return f"Load random vibe profile error: {self.message}"
356+
def str_itr(self):
357+
"""Create list of error messages."""
358+
if self.message is None:
359+
return [f"Load random vibe profile error: {error}" for error in self.error_array]
360+
361+
assert self.error_array is None
362+
return [f"Load random vibe profile error: {self.message}"]
358363

359364

360365
class SherlockLoadHarmonicProfileError(Exception):
361366
"""Contains the error raised when loading a harmonic profile."""
362367

363-
def __init__(self, message):
368+
def __init__(self, message=None, error_array=None):
364369
"""Initialize error message."""
365370
self.message = message
371+
self.error_array = error_array
366372

367-
def __str__(self):
368-
"""Format Error Message."""
369-
return f"Load Harmonic profile error: {self.message}"
373+
def str_itr(self):
374+
"""Create list of error messages."""
375+
if self.message is None:
376+
return [f"Load harmonic profile error: {error}" for error in self.error_array]
377+
378+
assert self.error_array is None
379+
return [f"Load harmonic profile error: {self.message}"]
370380

371381

372382
class SherlockUpdateMountPointsByFileError(Exception):
@@ -524,13 +534,18 @@ def __str__(self):
524534
class SherlockLoadThermalProfileError(Exception):
525535
"""Contains the error raised when loading thermal profile."""
526536

527-
def __init__(self, message):
537+
def __init__(self, message=None, error_array=None):
528538
"""Initialize error message."""
529539
self.message = message
540+
self.error_array = error_array
530541

531-
def __str__(self):
532-
"""Format error message."""
533-
return f"Load thermal profile error: {self.message}"
542+
def str_itr(self):
543+
"""Create list of error messages."""
544+
if self.message is None:
545+
return [f"Load thermal profile error: {error}" for error in self.error_array]
546+
547+
assert self.error_array is None
548+
return [f"Load thermal profile error: {self.message}"]
534549

535550

536551
class SherlockRunAnalysisError(Exception):
@@ -572,13 +587,18 @@ def __str__(self):
572587
class SherlockLoadShockProfileDatasetError(Exception):
573588
"""Contains the error raised when loading shock profile dataset results in an error."""
574589

575-
def __init__(self, message):
590+
def __init__(self, message=None, error_array=None):
576591
"""Initialize error message."""
577592
self.message = message
593+
self.error_array = error_array
578594

579-
def __str__(self):
580-
"""Initialize error message."""
581-
return f"Load shock profile dataset error: {self.message}"
595+
def str_itr(self):
596+
"""Create list of error messages."""
597+
if self.message is None:
598+
return [f"Load shock profile dataset error: {error}" for error in self.error_array]
599+
600+
assert self.error_array is None
601+
return [f"Load shock profile dataset error: {self.message}"]
582602

583603

584604
class SherlockUpdateNaturalFrequencyPropsError(Exception):
@@ -752,13 +772,18 @@ def __str__(self):
752772
class SherlockLoadShockProfilePulsesError(Exception):
753773
"""Contains the error raised when loading shock profile pulses."""
754774

755-
def __init__(self, message):
775+
def __init__(self, message=None, error_array=None):
756776
"""Initialize error message."""
757777
self.message = message
778+
self.error_array = error_array
758779

759-
def __str__(self):
760-
"""Format error message."""
761-
return f"Load shock profile pulses error: {self.message}"
780+
def str_itr(self):
781+
"""Create list of error messages."""
782+
if self.message is None:
783+
return [f"Load shock profile pulses error: {error}" for error in self.error_array]
784+
785+
assert self.error_array is None
786+
return [f"Load shock profile pulses error: {self.message}"]
762787

763788

764789
class SherlockUpdatePcbModelingPropsError(Exception):

0 commit comments

Comments
 (0)