File tree Expand file tree Collapse file tree 3 files changed +9
-2
lines changed
ubersmith_remote_module_server Expand file tree Collapse file tree 3 files changed +9
-2
lines changed Original file line number Diff line number Diff line change 1919import unittest
2020
2121from ubersmith_remote_module_server .api import Api
22+ from ubersmith_remote_module_server .exceptions import RemoteModuleException
2223
2324
2425class ApiTest (unittest .TestCase ):
@@ -69,7 +70,7 @@ def test_execute_method_returns_string(self):
6970 assert_that (output .status_code , is_ (200 ))
7071
7172 def test_execute_method_raise_an_exception (self ):
72- self .router .invoke_method .side_effect = Exception ('Some Error' )
73+ self .router .invoke_method .side_effect = RemoteModuleException ('Some Error' )
7374 output = self .api_client .post (self .generate_module_path ('module2' ),
7475 headers = {'Content-Type' : 'application/json' },
7576 data = json .dumps (
Original file line number Diff line number Diff line change 1717import logging
1818
1919from flask import request , current_app
20+ from ubersmith_remote_module_server .exceptions import RemoteModuleException
2021
2122
2223class Api (object ):
@@ -44,7 +45,8 @@ def handle_remote_invocation(self, module):
4445 try :
4546 output = self .router .invoke_method (module = module , ** data )
4647 return json_response (output , 200 )
47- except Exception as e :
48+ except RemoteModuleException as e :
49+ logging .exception (e )
4850 return json_response (str (e ), 500 )
4951
5052
Original file line number Diff line number Diff line change @@ -23,3 +23,7 @@ class NamedArgumentsOnly(Exception):
2323 def __init__ (self , msg = "UbersmithCore was called with non-named arguments, "
2424 "you MUST use named arguments (kwargs)" ):
2525 super (NamedArgumentsOnly , self ).__init__ (msg )
26+
27+
28+ class RemoteModuleException (Exception ):
29+ pass
You can’t perform that action at this time.
0 commit comments