Total Complexity | 2 |
Total Lines | 42 |
Duplicated Lines | 0 % |
Coverage | 0% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | """ |
||
15 | class NodeActionMessageWebEventHandler(NodeActionMessageBaseEventHandler): |
||
16 | """ |
||
17 | An event handler for a NodeActionWebMessage received events. |
||
18 | """ |
||
19 | |||
20 | # ------------------------------------------------------------------------------------------------------------------ |
||
21 | @staticmethod |
||
22 | def handle(_event, message, controller): |
||
23 | """ |
||
24 | Handles a NodeActionWebMessage received event. |
||
25 | |||
26 | :param * _event: Not used. |
||
27 | :param enarksh.controller.message.NodeActionWebMessage.NodeActionWebMessage message: The message. |
||
28 | :param enarksh.controller.Controller.Controller controller: The controller. |
||
29 | """ |
||
30 | del _event |
||
31 | |||
32 | # Compose a response message for the web interface. |
||
33 | response = {'ret': 0, |
||
34 | 'new_run': 0, |
||
35 | 'message': 'OK'} |
||
36 | |||
37 | try: |
||
38 | NodeActionMessageBaseEventHandler.base_handle(controller, |
||
39 | response, |
||
40 | message.sch_id, |
||
41 | message.rnd_id, |
||
42 | message.act_id, |
||
43 | message.usr_login, |
||
44 | message.mail_on_completion, |
||
45 | message.mail_on_error) |
||
46 | except Exception as exception: |
||
1 ignored issue
–
show
|
|||
47 | print(exception, file=sys.stderr) |
||
48 | traceback.print_exc(file=sys.stderr) |
||
49 | |||
50 | response['ret'] = -1 |
||
51 | response['message'] = 'Internal error' |
||
52 | |||
53 | DataLayer.rollback() |
||
54 | |||
55 | # Send the message to the web interface. |
||
56 | controller.message_controller.send_message('lockstep', response, True) |
||
57 | |||
59 |
Generally, you would want to handle very specific errors in the exception handler. This ensure that you do not hide other types of errors which should be fixed.
So, unless you specifically plan to handle any error, consider adding a more specific exception.