1
# -*- coding: utf-8 -*-
3
# vim: tabstop=4 shiftwidth=4 softtabstop=4
5
# Copyright (C) 2012 Yahoo! Inc. All Rights Reserved.
7
# Licensed under the Apache License, Version 2.0 (the "License"); you may
8
# not use this file except in compliance with the License. You may obtain
9
# a copy of the License at
11
# http://www.apache.org/licenses/LICENSE-2.0
13
# Unless required by applicable law or agreed to in writing, software
14
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16
# License for the specific language governing permissions and limitations
20
class TaskFlowException(Exception):
21
"""Base class for exceptions emitted from this library."""
25
class Duplicate(TaskFlowException):
26
"""Raised when a duplicate entry is found."""
30
class NotFound(TaskFlowException):
31
"""Raised when some entry in some object doesn't exist."""
35
class AlreadyExists(TaskFlowException):
36
"""Raised when some entry in some object already exists."""
40
class ClosedException(TaskFlowException):
41
"""Raised when an access on a closed object occurs."""
45
class InvalidStateException(TaskFlowException):
46
"""Raised when a task/job/workflow is in an invalid state when an
47
operation is attempting to apply to said task/job/workflow.
52
class UnclaimableJobException(TaskFlowException):
53
"""Raised when a job can not be claimed."""
57
class JobNotFound(TaskFlowException):
58
"""Raised when a job entry can not be found."""
62
class MissingDependencies(InvalidStateException):
63
"""Raised when a task has dependencies that can not be satisified."""
64
message = ("%(task)s requires %(requirements)s but no other task produces"
67
def __init__(self, task, requirements):
68
message = self.message % {'task': task, 'requirements': requirements}
69
super(MissingDependencies, self).__init__(message)