Source code for idmtools.core.exceptions
"""
Define idmtools common exception as well as idmtools system exception handler.
Copyright 2021, Bill & Melinda Gates Foundation. All rights reserved.
"""
import sys
import typing
from logging import getLogger
if typing.TYPE_CHECKING:
from idmtools.entities.iplatform import TPlatform
user_logger = getLogger('user')
logger = getLogger(__name__)
[docs]class ExperimentNotFound(Exception):
"""
Thrown when an experiment cannot be found on a platform.
"""
[docs] def __init__(self, experiment_id: str, platform: 'TPlatform' = None):
"""
Initialize our ExperimentNotFound.
Args:
experiment_id: Experiment id to say wasn't found
platform: Optional platform. Used in error message
"""
if platform:
super().__init__(f"Experiment with id '{experiment_id}' could not be retrieved on platform {platform}.")
else:
super().__init__(f"Experiment with id '{experiment_id}' could not be retrieved.")
[docs]class UnknownItemException(Exception):
"""
Thrown when an unknown item type is passed to idmtools.
This usually occurs within the platform operation area.
"""
pass
[docs]class TopLevelItem(Exception):
"""
Thrown when a parent of a top-level item is requested by the platform.
"""
pass
[docs]class NoTaskFound(Exception):
"""
Thrown when a simulation has no task defined.
"""
pass