add InvalidIsotopeError and DimensionError

This commit is contained in:
Pim Nelissen
2026-02-25 14:17:14 +01:00
parent bab41c128b
commit e926338b69
3 changed files with 16 additions and 5 deletions

View File

@ -14,12 +14,20 @@ class OutOfBoundsError(Exception):
"""Raised when an object is attempted to be placed out of bounds."""
class MissingNestedKeyError(Exception):
"""Raised when a nested key is missing in the config."""
class MissingConfigKeyError(KeyError):
"""Raised when a (nested) config key is missing in the config."""
def __init__(self, key, subkey=None):
if subkey:
self.message = f"Missing key in {key}: {subkey}"
self.message = f"Missing key in {key}: {', '.join(list(subkey))}"
else:
self.message = f"Missing key: {key}"
super().__init__(self.message)
class DimensionError(ValueError):
"""Raised if dimensions or coordinates do not match the system."""
class InvalidIsotopeError(ValueError):
"""Raised if attempting to load an isotope that is not valid."""