Edit on GitHub

common.lib.exceptions

  1import traceback
  2
  3
  4class FourcatException(Exception):
  5    """
  6    Base 4CAT exception class
  7    """
  8
  9    def __init__(self, message="", frame=None):
 10        """
 11        Exception constructor
 12
 13        Takes an optional extra argument, `frame`, the traceback frame of the
 14        offending code.
 15
 16        :param str message:  Exception message
 17        :param frame:  Traceback frame. If omitted, the frame is extrapolated
 18        from the context.
 19        """
 20        super().__init__(message)
 21        if not frame:
 22            frame = traceback.extract_stack()[-2]
 23
 24        self.frame = frame
 25
 26
 27class ConfigException(FourcatException):
 28    """
 29    Raised when there is a problem with the configuration settings.
 30    """
 31    pass
 32
 33
 34class QueueException(FourcatException):
 35    """
 36    General Queue Exception - only children are to be used
 37    """
 38    pass
 39
 40
 41class ProcessorException(FourcatException):
 42    """
 43    Raise if processor throws an exception
 44    """
 45    pass
 46
 47class AnnotationException(FourcatException):
 48    """
 49    Raise for exceptions with setting/getting annotations.
 50    """
 51    pass
 52
 53class MapItemException(ProcessorException):
 54    """
 55    Raise if processor throws an exception
 56    """
 57    pass
 58
 59
 60class MappedItemIncompleteException(MapItemException):
 61    """
 62    Raise if processor encounters a mapped item and map_missing = 'abort'
 63    """
 64    pass
 65
 66
 67class DataSetException(FourcatException):
 68    """
 69    Raise if dataset throws an exception
 70    """
 71    pass
 72
 73
 74class DataSetNotFoundException(DataSetException):
 75    """
 76    Raise if dataset does not exist
 77    """
 78    pass
 79
 80
 81class CsvDialectException(FourcatException):
 82    """
 83    Raised when there is a problem with the configuration settings.
 84    """
 85    pass
 86
 87
 88class JobClaimedException(QueueException):
 89    """
 90    Raise if job is claimed, but is already marked as such
 91    """
 92    pass
 93
 94
 95class JobAlreadyExistsException(QueueException):
 96    """
 97    Raise if a job is created, but a job with the same type/remote_id combination already exists
 98    """
 99    pass
100
101
102class JobNotFoundException(QueueException):
103    """
104    Raise if trying to instantiate a job with an ID that is not valid
105    """
106    pass
107
108
109class QueryException(FourcatException):
110    """
111    Raise if there is an issue with form input while creating a dataset
112    """
113    pass
114
115
116class QueryParametersException(QueryException):
117    """
118    Raise if a dataset query has invalid parameters
119    """
120    pass
121
122
123class QueryNeedsExplicitConfirmationException(QueryException):
124    """
125    Raise if a dataset query needs confirmation
126    """
127    pass
128
129
130class QueryNeedsFurtherInputException(QueryException):
131    """
132    Raise if a dataset requires further user input
133    """
134
135    def __init__(self, config):
136        super(QueryNeedsFurtherInputException, self).__init__()
137        self.config = config
138
139
140class WorkerInterruptedException(FourcatException):
141    """
142    Raise when killing a worker before it's done with its job
143    """
144    pass
145
146
147class ProcessorInterruptedException(WorkerInterruptedException):
148    """
149    Raise when killing a processor before it's done with its job
150    """
151    pass
152
153
154class DatabaseQueryInterruptedException(WorkerInterruptedException):
155    """
156    Raise when interrupting a DB query before it has finished
157    """
158    pass
class FourcatException(builtins.Exception):
 5class FourcatException(Exception):
 6    """
 7    Base 4CAT exception class
 8    """
 9
10    def __init__(self, message="", frame=None):
11        """
12        Exception constructor
13
14        Takes an optional extra argument, `frame`, the traceback frame of the
15        offending code.
16
17        :param str message:  Exception message
18        :param frame:  Traceback frame. If omitted, the frame is extrapolated
19        from the context.
20        """
21        super().__init__(message)
22        if not frame:
23            frame = traceback.extract_stack()[-2]
24
25        self.frame = frame

Base 4CAT exception class

FourcatException(message='', frame=None)
10    def __init__(self, message="", frame=None):
11        """
12        Exception constructor
13
14        Takes an optional extra argument, `frame`, the traceback frame of the
15        offending code.
16
17        :param str message:  Exception message
18        :param frame:  Traceback frame. If omitted, the frame is extrapolated
19        from the context.
20        """
21        super().__init__(message)
22        if not frame:
23            frame = traceback.extract_stack()[-2]
24
25        self.frame = frame

Exception constructor

Takes an optional extra argument, frame, the traceback frame of the offending code.

Parameters
  • str message: Exception message
  • frame: Traceback frame. If omitted, the frame is extrapolated from the context.
frame
class ConfigException(FourcatException):
28class ConfigException(FourcatException):
29    """
30    Raised when there is a problem with the configuration settings.
31    """
32    pass

Raised when there is a problem with the configuration settings.

class QueueException(FourcatException):
35class QueueException(FourcatException):
36    """
37    General Queue Exception - only children are to be used
38    """
39    pass

General Queue Exception - only children are to be used

class ProcessorException(FourcatException):
42class ProcessorException(FourcatException):
43    """
44    Raise if processor throws an exception
45    """
46    pass

Raise if processor throws an exception

class AnnotationException(FourcatException):
48class AnnotationException(FourcatException):
49    """
50    Raise for exceptions with setting/getting annotations.
51    """
52    pass

Raise for exceptions with setting/getting annotations.

class MapItemException(ProcessorException):
54class MapItemException(ProcessorException):
55    """
56    Raise if processor throws an exception
57    """
58    pass

Raise if processor throws an exception

class MappedItemIncompleteException(MapItemException):
61class MappedItemIncompleteException(MapItemException):
62    """
63    Raise if processor encounters a mapped item and map_missing = 'abort'
64    """
65    pass

Raise if processor encounters a mapped item and map_missing = 'abort'

class DataSetException(FourcatException):
68class DataSetException(FourcatException):
69    """
70    Raise if dataset throws an exception
71    """
72    pass

Raise if dataset throws an exception

class DataSetNotFoundException(DataSetException):
75class DataSetNotFoundException(DataSetException):
76    """
77    Raise if dataset does not exist
78    """
79    pass

Raise if dataset does not exist

class CsvDialectException(FourcatException):
82class CsvDialectException(FourcatException):
83    """
84    Raised when there is a problem with the configuration settings.
85    """
86    pass

Raised when there is a problem with the configuration settings.

class JobClaimedException(QueueException):
89class JobClaimedException(QueueException):
90    """
91    Raise if job is claimed, but is already marked as such
92    """
93    pass

Raise if job is claimed, but is already marked as such

class JobAlreadyExistsException(QueueException):
 96class JobAlreadyExistsException(QueueException):
 97    """
 98    Raise if a job is created, but a job with the same type/remote_id combination already exists
 99    """
100    pass

Raise if a job is created, but a job with the same type/remote_id combination already exists

class JobNotFoundException(QueueException):
103class JobNotFoundException(QueueException):
104    """
105    Raise if trying to instantiate a job with an ID that is not valid
106    """
107    pass

Raise if trying to instantiate a job with an ID that is not valid

class QueryException(FourcatException):
110class QueryException(FourcatException):
111    """
112    Raise if there is an issue with form input while creating a dataset
113    """
114    pass

Raise if there is an issue with form input while creating a dataset

class QueryParametersException(QueryException):
117class QueryParametersException(QueryException):
118    """
119    Raise if a dataset query has invalid parameters
120    """
121    pass

Raise if a dataset query has invalid parameters

class QueryNeedsExplicitConfirmationException(QueryException):
124class QueryNeedsExplicitConfirmationException(QueryException):
125    """
126    Raise if a dataset query needs confirmation
127    """
128    pass

Raise if a dataset query needs confirmation

class QueryNeedsFurtherInputException(QueryException):
131class QueryNeedsFurtherInputException(QueryException):
132    """
133    Raise if a dataset requires further user input
134    """
135
136    def __init__(self, config):
137        super(QueryNeedsFurtherInputException, self).__init__()
138        self.config = config

Raise if a dataset requires further user input

QueryNeedsFurtherInputException(config)
136    def __init__(self, config):
137        super(QueryNeedsFurtherInputException, self).__init__()
138        self.config = config

Exception constructor

Takes an optional extra argument, frame, the traceback frame of the offending code.

Parameters
  • str message: Exception message
  • frame: Traceback frame. If omitted, the frame is extrapolated from the context.
config
Inherited Members
FourcatException
frame
class WorkerInterruptedException(FourcatException):
141class WorkerInterruptedException(FourcatException):
142    """
143    Raise when killing a worker before it's done with its job
144    """
145    pass

Raise when killing a worker before it's done with its job

class ProcessorInterruptedException(WorkerInterruptedException):
148class ProcessorInterruptedException(WorkerInterruptedException):
149    """
150    Raise when killing a processor before it's done with its job
151    """
152    pass

Raise when killing a processor before it's done with its job

class DatabaseQueryInterruptedException(WorkerInterruptedException):
155class DatabaseQueryInterruptedException(WorkerInterruptedException):
156    """
157    Raise when interrupting a DB query before it has finished
158    """
159    pass

Raise when interrupting a DB query before it has finished