|
1 | | -class TembaException(Exception): |
2 | | - def __str__(self): |
3 | | - return self.message |
4 | | - |
5 | | - |
6 | | -class TembaConnectionError(TembaException): |
7 | | - message = "Unable to connect to host" |
8 | | - |
9 | | - |
10 | | -class TembaBadRequestError(TembaException): |
11 | | - def __init__(self, errors): |
12 | | - self.errors = errors |
13 | | - |
14 | | - def __str__(self): |
15 | | - msgs = [] |
16 | | - if isinstance(self.errors, dict): |
17 | | - for field, field_errors in self.errors.items(): |
18 | | - if isinstance(field_errors, str): # e.g. {"detail": "message..."} |
19 | | - msgs.append(field_errors) |
20 | | - else: |
21 | | - for error in field_errors: # e.g. {"field1": ["msg1...", "msg2..."]} |
22 | | - msgs.append(error) |
23 | | - elif isinstance(self.errors, list): |
24 | | - msgs = self.errors |
25 | | - |
26 | | - return msgs[0] if len(msgs) == 1 else ". ".join(msgs) |
27 | | - |
28 | | - |
29 | | -class TembaTokenError(TembaException): |
30 | | - message = "Authentication with provided token failed" |
31 | | - |
32 | | - |
33 | | -class TembaNoSuchObjectError(TembaException): |
34 | | - message = "No such object exists" |
35 | | - |
36 | | - |
37 | | -class TembaRateExceededError(TembaException): |
38 | | - message = ( |
39 | | - "You have exceeded the number of requests allowed per org in a given time window. " |
40 | | - "Please wait %d seconds before making further requests" |
41 | | - ) |
42 | | - |
43 | | - def __init__(self, retry_after): |
44 | | - self.retry_after = retry_after |
45 | | - |
46 | | - def __str__(self): |
47 | | - return self.message % self.retry_after |
48 | | - |
49 | | - |
50 | | -class TembaHttpError(TembaException): |
51 | | - def __init__(self, caused_by): |
52 | | - self.caused_by = caused_by |
53 | | - |
54 | | - def __str__(self): |
55 | | - return str(self.caused_by) |
56 | | - |
57 | | - |
58 | | -class TembaSerializationException(TembaException): |
59 | | - def __init__(self, message): |
60 | | - self.message = message |
| 1 | +[ |
| 2 | + { |
| 3 | + "code": "E902", |
| 4 | + "message": "No such file or directory (os error 2)", |
| 5 | + "fix": None, |
| 6 | + "location": { |
| 7 | + "row": 0, |
| 8 | + "column": 0 |
| 9 | + }, |
| 10 | + "end_location": { |
| 11 | + "row": 0, |
| 12 | + "column": 0 |
| 13 | + }, |
| 14 | + "filename": "/Users/norbert/nyaruka/rapidpro-python/-" |
| 15 | + }, |
| 16 | + { |
| 17 | + "code": "E902", |
| 18 | + "message": "No such file or directory (os error 2)", |
| 19 | + "fix": None, |
| 20 | + "location": { |
| 21 | + "row": 0, |
| 22 | + "column": 0 |
| 23 | + }, |
| 24 | + "end_location": { |
| 25 | + "row": 0, |
| 26 | + "column": 0 |
| 27 | + }, |
| 28 | + "filename": "/Users/norbert/nyaruka/rapidpro-python/check" |
| 29 | + } |
| 30 | +] |
0 commit comments