Meshroom/meshroom/core/exception.py
Yann Lanthony ab4e82aa88 [core] add GraphVisitMessage exceptions mecanism
allow to stop branch or graph visit by throwing specific exceptions in visitor callbacks
2018-07-19 13:50:45 +02:00

45 lines
1.1 KiB
Python

#!/usr/bin/env python
# coding:utf-8
class MeshroomException(Exception):
""" Base class for Meshroom exceptions """
pass
class GraphException(MeshroomException):
""" Base class for Graph exceptions """
pass
class UnknownNodeTypeError(GraphException):
"""
Raised when asked to create a unknown node type.
"""
def __init__(self, nodeType, msg=None):
msg = "Unknown Node Type: " + nodeType
super(UnknownNodeTypeError, self).__init__(msg)
self.nodeType = nodeType
class NodeUpgradeError(GraphException):
def __init__(self, nodeName, details=None):
msg = "Failed to upgrade node {}".format(nodeName)
if details:
msg += ": {}".format(details)
super(NodeUpgradeError, self).__init__(msg)
class GraphVisitMessage(GraphException):
""" Base class for sending messages via exceptions during a graph visit. """
pass
class StopGraphVisit(GraphVisitMessage):
""" Immediately interrupt graph visit. """
pass
class StopBranchVisit(GraphVisitMessage):
""" Immediately stop branch visit. """
pass