refs #703 add support for HTTP error codes, have process_CrearImagenBasica() return 404
parent
b58c2c1f7f
commit
8686b09d0e
|
@ -92,7 +92,26 @@ class HTTPServerHandler(BaseHTTPRequestHandler):
|
|||
self.sendJsonResponse(data)
|
||||
except Exception as e:
|
||||
logger.exception()
|
||||
self.sendJsonError(500, exceptionToMessage(e))
|
||||
n_args = len (e.args)
|
||||
if 0 == n_args:
|
||||
logger.error ('Empty exception raised from message processor for "{}"'.format(path[0]))
|
||||
self.sendJsonError(500, exceptionToMessage(e))
|
||||
else:
|
||||
arg0 = e.args[0]
|
||||
if type (arg0) is str:
|
||||
logger.error ('Message processor for "{}" returned exception string "{}"'.format(path[0], str(e)))
|
||||
self.sendJsonError (500, exceptionToMessage(e))
|
||||
elif type (arg0) is dict:
|
||||
if '_httpcode' in arg0:
|
||||
logger.warning ('Message processor for "{}" returned HTTP code "{}" with exception string "{}"'.format(path[0], str(arg0['_httpcode']), str(arg0['_msg'])))
|
||||
self.sendJsonError (arg0['_httpcode'], arg0['_msg'])
|
||||
else:
|
||||
logger.error ('Message processor for "{}" returned exception dict "{}" with no HTTP code'.format(path[0], str(e)))
|
||||
self.sendJsonError (500, exceptionToMessage(e))
|
||||
else:
|
||||
logger.error ('Message processor for "{}" returned non-string and non-dict exception "{}"'.format(path[0], str(e)))
|
||||
self.sendJsonError (500, exceptionToMessage(e))
|
||||
## not reached
|
||||
|
||||
def do_GET(self):
|
||||
module, path, params = self.parseUrl()
|
||||
|
|
|
@ -701,7 +701,9 @@ class ogAdmClientWorker (ServerWorker):
|
|||
return self.respuestaEjecucionComando (cmd, herror, ids)
|
||||
|
||||
def process_CrearImagenBasica (self, path, get_params, post_params, server):
|
||||
logger.warning ('in process_CrearImagenBasica')
|
||||
logger.debug ('in process_CrearImagenBasica, path "{}" get_params "{}" post_params "{}" server "{}"'.format (path, get_params, post_params, server))
|
||||
logger.warning ('this method has been removed')
|
||||
raise Exception ({ '_httpcode': 404, '_msg': 'This method has been removed' })
|
||||
|
||||
def process_CrearSoftIncremental (self, path, get_params, post_params, server):
|
||||
logger.warning ('in process_CrearSoftIncremental')
|
||||
|
|
|
@ -96,8 +96,8 @@ class ServerWorker(object):
|
|||
return self.process(getParams, postParams, server)
|
||||
try:
|
||||
operation = getattr(self, 'process_' + path[0])
|
||||
except Exception:
|
||||
raise Exception('Message processor for "{}" not found'.format(path[0]))
|
||||
except:
|
||||
raise Exception ({ '_httpcode': 404, '_msg': '{path[0]}: method not found' })
|
||||
|
||||
return operation(path[1:], getParams, postParams, server)
|
||||
|
||||
|
|
Loading…
Reference in New Issue