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
 47
 48class MapItemException(ProcessorException):
 49    """
 50    Raise if processor throws an exception
 51    """
 52    pass
 53
 54
 55class MappedItemIncompleteException(MapItemException):
 56    """
 57    Raise if processor encounters a mapped item and map_missing = 'abort'
 58    """
 59    pass
 60
 61
 62class DataSetException(FourcatException):
 63    """
 64    Raise if dataset throws an exception
 65    """
 66    pass
 67
 68
 69class DataSetNotFoundException(DataSetException):
 70    """
 71    Raise if dataset does not exist
 72    """
 73    pass
 74
 75
 76class CsvDialectException(FourcatException):
 77    """
 78    Raised when there is a problem with the configuration settings.
 79    """
 80    pass
 81
 82
 83class JobClaimedException(QueueException):
 84    """
 85    Raise if job is claimed, but is already marked as such
 86    """
 87    pass
 88
 89
 90class JobAlreadyExistsException(QueueException):
 91    """
 92    Raise if a job is created, but a job with the same type/remote_id combination already exists
 93    """
 94    pass
 95
 96
 97class JobNotFoundException(QueueException):
 98    """
 99    Raise if trying to instantiate a job with an ID that is not valid
100    """
101    pass
102
103
104class QueryException(FourcatException):
105    """
106    Raise if there is an issue with form input while creating a dataset
107    """
108    pass
109
110
111class QueryParametersException(QueryException):
112    """
113    Raise if a dataset query has invalid parameters
114    """
115    pass
116
117
118class QueryNeedsExplicitConfirmationException(QueryException):
119    """
120    Raise if a dataset query needs confirmation
121    """
122    pass
123
124
125class QueryNeedsFurtherInputException(QueryException):
126    """
127    Raise if a dataset requires further user input
128    """
129
130    def __init__(self, config):
131        super(QueryNeedsFurtherInputException, self).__init__()
132        self.config = config
133
134
135class WorkerInterruptedException(FourcatException):
136    """
137    Raise when killing a worker before it's done with its job
138    """
139    pass
140
141
142class ProcessorInterruptedException(WorkerInterruptedException):
143    """
144    Raise when killing a processor before it's done with its job
145    """
146    pass
147
148
149class DatabaseQueryInterruptedException(WorkerInterruptedException):
150    """
151    Raise when interrupting a DB query before it has finished
152    """
153    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 MapItemException(ProcessorException):
49class MapItemException(ProcessorException):
50    """
51    Raise if processor throws an exception
52    """
53    pass

Raise if processor throws an exception

class MappedItemIncompleteException(MapItemException):
56class MappedItemIncompleteException(MapItemException):
57    """
58    Raise if processor encounters a mapped item and map_missing = 'abort'
59    """
60    pass

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

class DataSetException(FourcatException):
63class DataSetException(FourcatException):
64    """
65    Raise if dataset throws an exception
66    """
67    pass

Raise if dataset throws an exception

class DataSetNotFoundException(DataSetException):
70class DataSetNotFoundException(DataSetException):
71    """
72    Raise if dataset does not exist
73    """
74    pass

Raise if dataset does not exist

class CsvDialectException(FourcatException):
77class CsvDialectException(FourcatException):
78    """
79    Raised when there is a problem with the configuration settings.
80    """
81    pass

Raised when there is a problem with the configuration settings.

class JobClaimedException(QueueException):
84class JobClaimedException(QueueException):
85    """
86    Raise if job is claimed, but is already marked as such
87    """
88    pass

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

class JobAlreadyExistsException(QueueException):
91class JobAlreadyExistsException(QueueException):
92    """
93    Raise if a job is created, but a job with the same type/remote_id combination already exists
94    """
95    pass

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

class JobNotFoundException(QueueException):
 98class JobNotFoundException(QueueException):
 99    """
100    Raise if trying to instantiate a job with an ID that is not valid
101    """
102    pass

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

class QueryException(FourcatException):
105class QueryException(FourcatException):
106    """
107    Raise if there is an issue with form input while creating a dataset
108    """
109    pass

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

class QueryParametersException(QueryException):
112class QueryParametersException(QueryException):
113    """
114    Raise if a dataset query has invalid parameters
115    """
116    pass

Raise if a dataset query has invalid parameters

class QueryNeedsExplicitConfirmationException(QueryException):
119class QueryNeedsExplicitConfirmationException(QueryException):
120    """
121    Raise if a dataset query needs confirmation
122    """
123    pass

Raise if a dataset query needs confirmation

class QueryNeedsFurtherInputException(QueryException):
126class QueryNeedsFurtherInputException(QueryException):
127    """
128    Raise if a dataset requires further user input
129    """
130
131    def __init__(self, config):
132        super(QueryNeedsFurtherInputException, self).__init__()
133        self.config = config

Raise if a dataset requires further user input

QueryNeedsFurtherInputException(config)
131    def __init__(self, config):
132        super(QueryNeedsFurtherInputException, self).__init__()
133        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):
136class WorkerInterruptedException(FourcatException):
137    """
138    Raise when killing a worker before it's done with its job
139    """
140    pass

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

class ProcessorInterruptedException(WorkerInterruptedException):
143class ProcessorInterruptedException(WorkerInterruptedException):
144    """
145    Raise when killing a processor before it's done with its job
146    """
147    pass

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

class DatabaseQueryInterruptedException(WorkerInterruptedException):
150class DatabaseQueryInterruptedException(WorkerInterruptedException):
151    """
152    Raise when interrupting a DB query before it has finished
153    """
154    pass

Raise when interrupting a DB query before it has finished