|
1 | | - |
2 | 1 | class ConnectionException(Exception): |
3 | | - def __init__(self, err_message = "error"): |
| 2 | + def __init__(self, err_message="error"): |
4 | 3 | # Call the base class constructor with the parameters it needs |
5 | | - super(ConnectionException, self).__init__("Could not establish connection! Error type: " + err_message) |
| 4 | + super(ConnectionException, self).__init__( |
| 5 | + "Could not establish connection! Error type: " + err_message |
| 6 | + ) |
| 7 | + |
6 | 8 |
|
7 | 9 | class CommandException(Exception): |
8 | | - def __init__(self, err_message = "error"): |
| 10 | + def __init__(self, err_message="error"): |
9 | 11 | super(CommandException, self).__init__( |
10 | | - "Invalid command! Check if communication is open. Error type: " + err_message |
| 12 | + "Invalid command! Check if communication is open. Error type: " |
| 13 | + + err_message |
11 | 14 | ) |
12 | 15 |
|
| 16 | + |
13 | 17 | class ErrorResponse(Exception): |
14 | 18 | """Error during command execution..""" |
15 | 19 |
|
16 | 20 | @staticmethod |
17 | 21 | def from_error_code(error: str): |
18 | 22 | error_codes = { |
19 | | - "-1009":"*No robot attached*", |
20 | | - "-1012":"*Joint out-of-range* Set robot joints within their range", |
21 | | - "-1039":"*Position too close* Robot 1", |
22 | | - "-1040":"*Position too far* Robot 1", |
23 | | - "-1042":"*Can't change robot config* Robot 1", |
24 | | - "-1046":"*Power not enabled*", |
25 | | - "-1600":"*Power off requested*", |
26 | | - "-2800":"*Warning Parameter Mismatch*", |
27 | | - "-2801":"*Warning No Parameters", |
28 | | - "-2802":"*Warning Illegal move command*", |
29 | | - "-2803":"*Warning Invalid joint angles*", |
30 | | - "-2804":"*Warning: Invalid Cartesian coordinate values*", |
31 | | - "-2805":"*Unknown command* ", |
32 | | - "-2806":"*Command Exception*", |
33 | | - "-2807":"*Warning cannot set Input states*", |
34 | | - "-2808":"*Not allowed by this thread*", |
35 | | - "-2809":"*Invalid robot type*", |
36 | | - "-2810":"*Invalid serial command*", |
37 | | - "-2811":"*Invalid robot number*", |
38 | | - "-2812":"*Robot already selected*", |
39 | | - "-2813":"*Module not initialized*", |
40 | | - "-2814":"*Invalid location index*", |
41 | | - "-2816":"*Undefined location*", |
42 | | - "-2817":"*Undefined profile*", |
43 | | - "-2818":"*Undefined pallet*", |
44 | | - "-2819":"*Pallet not supported*", |
45 | | - "-2820":"*Invalid station index*", |
46 | | - "-2821":"*Undefined station*", |
47 | | - "-2822":"*Not a pallet*", |
48 | | - "-2823":"*Not at pallet origin*", |
49 | | - "-3122":"*Soft envelope error* Robot 1: 1" |
| 23 | + "-1009": "*No robot attached*", |
| 24 | + "-1012": "*Joint out-of-range* Set robot joints within their range", |
| 25 | + "-1039": "*Position too close* Robot 1", |
| 26 | + "-1040": "*Position too far* Robot 1", |
| 27 | + "-1042": "*Can't change robot config* Robot 1", |
| 28 | + "-1046": "*Power not enabled*", |
| 29 | + "-1600": "*Power off requested*", |
| 30 | + "-2800": "*Warning Parameter Mismatch*", |
| 31 | + "-2801": "*Warning No Parameters", |
| 32 | + "-2802": "*Warning Illegal move command*", |
| 33 | + "-2803": "*Warning Invalid joint angles*", |
| 34 | + "-2804": "*Warning: Invalid Cartesian coordinate values*", |
| 35 | + "-2805": "*Unknown command* ", |
| 36 | + "-2806": "*Command Exception*", |
| 37 | + "-2807": "*Warning cannot set Input states*", |
| 38 | + "-2808": "*Not allowed by this thread*", |
| 39 | + "-2809": "*Invalid robot type*", |
| 40 | + "-2810": "*Invalid serial command*", |
| 41 | + "-2811": "*Invalid robot number*", |
| 42 | + "-2812": "*Robot already selected*", |
| 43 | + "-2813": "*Module not initialized*", |
| 44 | + "-2814": "*Invalid location index*", |
| 45 | + "-2816": "*Undefined location*", |
| 46 | + "-2817": "*Undefined profile*", |
| 47 | + "-2818": "*Undefined pallet*", |
| 48 | + "-2819": "*Pallet not supported*", |
| 49 | + "-2820": "*Invalid station index*", |
| 50 | + "-2821": "*Undefined station*", |
| 51 | + "-2822": "*Not a pallet*", |
| 52 | + "-2823": "*Not at pallet origin*", |
| 53 | + "-3122": "*Soft envelope error* Robot 1: 1", |
50 | 54 | } |
51 | 55 | if error not in error_codes: |
52 | 56 | return ErrorResponse(f"Unknown error code: {error}") |
53 | 57 | return ErrorResponse(error_codes[error]) |
54 | | - |
|
0 commit comments