root / snf-astakos-app / astakos / quotaholder_app / exception.py @ daa780fa
History | View | Annotate | Download (2.5 kB)
1 | b0727daf | Giorgos Korfiatis | # Copyright 2012, 2013 GRNET S.A. All rights reserved.
|
---|---|---|---|
2 | b0727daf | Giorgos Korfiatis | #
|
3 | b0727daf | Giorgos Korfiatis | # Redistribution and use in source and binary forms, with or
|
4 | b0727daf | Giorgos Korfiatis | # without modification, are permitted provided that the following
|
5 | b0727daf | Giorgos Korfiatis | # conditions are met:
|
6 | b0727daf | Giorgos Korfiatis | #
|
7 | b0727daf | Giorgos Korfiatis | # 1. Redistributions of source code must retain the above
|
8 | b0727daf | Giorgos Korfiatis | # copyright notice, this list of conditions and the following
|
9 | b0727daf | Giorgos Korfiatis | # disclaimer.
|
10 | b0727daf | Giorgos Korfiatis | #
|
11 | b0727daf | Giorgos Korfiatis | # 2. Redistributions in binary form must reproduce the above
|
12 | b0727daf | Giorgos Korfiatis | # copyright notice, this list of conditions and the following
|
13 | b0727daf | Giorgos Korfiatis | # disclaimer in the documentation and/or other materials
|
14 | b0727daf | Giorgos Korfiatis | # provided with the distribution.
|
15 | b0727daf | Giorgos Korfiatis | #
|
16 | b0727daf | Giorgos Korfiatis | # THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
|
17 | b0727daf | Giorgos Korfiatis | # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
18 | b0727daf | Giorgos Korfiatis | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
19 | b0727daf | Giorgos Korfiatis | # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
|
20 | b0727daf | Giorgos Korfiatis | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
21 | b0727daf | Giorgos Korfiatis | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
22 | b0727daf | Giorgos Korfiatis | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
23 | b0727daf | Giorgos Korfiatis | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
24 | b0727daf | Giorgos Korfiatis | # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
25 | b0727daf | Giorgos Korfiatis | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
26 | b0727daf | Giorgos Korfiatis | # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
27 | b0727daf | Giorgos Korfiatis | # POSSIBILITY OF SUCH DAMAGE.
|
28 | b0727daf | Giorgos Korfiatis | #
|
29 | b0727daf | Giorgos Korfiatis | # The views and conclusions contained in the software and
|
30 | b0727daf | Giorgos Korfiatis | # documentation are those of the authors and should not be
|
31 | b0727daf | Giorgos Korfiatis | # interpreted as representing official policies, either expressed
|
32 | b0727daf | Giorgos Korfiatis | # or implied, of GRNET S.A.
|
33 | b0727daf | Giorgos Korfiatis | |
34 | b0727daf | Giorgos Korfiatis | |
35 | b0727daf | Giorgos Korfiatis | class QuotaholderError(Exception): |
36 | b0727daf | Giorgos Korfiatis | pass
|
37 | b0727daf | Giorgos Korfiatis | |
38 | b0727daf | Giorgos Korfiatis | |
39 | 79e3da8a | Giorgos Korfiatis | class NoCommissionError(QuotaholderError): |
40 | 79e3da8a | Giorgos Korfiatis | pass
|
41 | 79e3da8a | Giorgos Korfiatis | |
42 | 79e3da8a | Giorgos Korfiatis | |
43 | b0727daf | Giorgos Korfiatis | class CorruptedError(QuotaholderError): |
44 | b0727daf | Giorgos Korfiatis | pass
|
45 | b0727daf | Giorgos Korfiatis | |
46 | b0727daf | Giorgos Korfiatis | |
47 | b0727daf | Giorgos Korfiatis | class InvalidDataError(QuotaholderError): |
48 | b0727daf | Giorgos Korfiatis | pass
|
49 | b0727daf | Giorgos Korfiatis | |
50 | b0727daf | Giorgos Korfiatis | |
51 | b0727daf | Giorgos Korfiatis | class CommissionException(QuotaholderError): |
52 | 79e3da8a | Giorgos Korfiatis | data = {} |
53 | 79e3da8a | Giorgos Korfiatis | |
54 | e311d555 | Giorgos Korfiatis | def add_data(self, kwargs, key): |
55 | e311d555 | Giorgos Korfiatis | value = kwargs.pop(key, None)
|
56 | e311d555 | Giorgos Korfiatis | if value is not None: |
57 | e311d555 | Giorgos Korfiatis | self.data[key] = value
|
58 | e311d555 | Giorgos Korfiatis | |
59 | 79e3da8a | Giorgos Korfiatis | def __init__(self, *args, **kwargs): |
60 | 79e3da8a | Giorgos Korfiatis | self.data['name'] = self.__class__.__name__ |
61 | e311d555 | Giorgos Korfiatis | self.add_data(kwargs, 'provision') |
62 | b0727daf | Giorgos Korfiatis | |
63 | 79e3da8a | Giorgos Korfiatis | QuotaholderError.__init__(self, *args, **kwargs)
|
64 | 79e3da8a | Giorgos Korfiatis | |
65 | 79e3da8a | Giorgos Korfiatis | |
66 | 3a8e56bc | Giorgos Korfiatis | class OverLimitError(CommissionException): |
67 | b0727daf | Giorgos Korfiatis | def __init__(self, *args, **kwargs): |
68 | e311d555 | Giorgos Korfiatis | self.add_data(kwargs, 'usage') |
69 | e311d555 | Giorgos Korfiatis | self.add_data(kwargs, 'limit') |
70 | d03796c2 | Giorgos Korfiatis | CommissionException.__init__(self, *args, **kwargs)
|
71 | b0727daf | Giorgos Korfiatis | |
72 | b0727daf | Giorgos Korfiatis | |
73 | 3a8e56bc | Giorgos Korfiatis | class NoCapacityError(OverLimitError): |
74 | 3a8e56bc | Giorgos Korfiatis | pass
|
75 | 3a8e56bc | Giorgos Korfiatis | |
76 | 3a8e56bc | Giorgos Korfiatis | |
77 | 3a8e56bc | Giorgos Korfiatis | class NoQuantityError(OverLimitError): |
78 | 3a8e56bc | Giorgos Korfiatis | pass
|
79 | b0727daf | Giorgos Korfiatis | |
80 | b0727daf | Giorgos Korfiatis | |
81 | 79e3da8a | Giorgos Korfiatis | class NoHoldingError(CommissionException): |
82 | d03796c2 | Giorgos Korfiatis | pass |