Source

quantumcore.experiments / exc.py

Full commit



class QuantumBusterException(Exception):
    """superclass for all QuantumBuster related errors"""
    
# storage related exceptions


class StorageError(QuantumBusterException):
    """general storage related error"""
    

class ObjectNotFound(StorageError):
    """an object couldn't be found"""
    
    def __init__(self, id):
        self.id = id
        
    def __str__(self):
        return u"couldn't find object with id <%s>" %repr(self.id)
        

class DuplicateNodeName(QuantumBusterException):
    """a child node with an already existing name has been tried to be added to a node"""
    
    def __init__(self, node, existing_node, parent_node, name):
        self.node = node # the node which was tried to be added
        self.existing_node = existing_node # the node which already is attached to the parent with the same name
        self.parent_node = parent_node # the parent node
        self.name = name # the colliding name
        
    def __str__(self):
        return u"parent node <%s> already contains node <%s> with the name '%s'" %(self.parent_node.node_id, 
                self.existing_node.node_id, self.name)
        
        
class StorageError(QuantumBusterException):
    """a generic Storage error"""
    
    def __init__(self, storage, msg):
        self.storage = storage
        self.msg = msg
        
    def __str__(self):
        return self.msg