From a418000fa2b28cd680ad860ef42800e467176751 Mon Sep 17 00:00:00 2001 From: Josh Borrow Date: Fri, 6 Oct 2023 11:25:53 -0400 Subject: [PATCH] Create invalid snapshot exception --- swiftsimio/objects.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/swiftsimio/objects.py b/swiftsimio/objects.py index 0eaa1412..eee5912b 100644 --- a/swiftsimio/objects.py +++ b/swiftsimio/objects.py @@ -381,6 +381,32 @@ def __str__(self): Print warning message of invalid scale factor """ return f"InvalidScaleFactor: {self.message}" + + +class InvalidSnapshot(Exception): + """ + Generated when a snapshot is invalid (e.g. you are trying to partially load a + sub-snapshot). + """ + + def __init__(self, message=None, *args): + """ + Constructor for warning of invalid snapshot + + Parameters + ---------- + + message : str, optional + Message to print in case of invalid snapshot + """ + self.message = message + + def __str__(self): + """ + Print warning message of invalid snapshot + """ + return f"InvalidSnapshot: {self.message}" + class cosmo_factor: