Skip to content
Snippets Groups Projects
Commit 1532b80d authored by Renaud Le Gac's avatar Renaud Le Gac
Browse files

Modify the error method to handle error code and message.

parent 71bf31d0
No related branches found
No related tags found
No related merge requests found
......@@ -6,6 +6,7 @@ __version__ = "$Revision$"
import pprint
import traceback
import sys
from gluon.contrib import simplejson as json
......@@ -74,7 +75,7 @@ class DirectSvc(object):
if len(request.args) == 1 and request.args(0) == 'get_api':
return self.get_api()
self.error()
self.error(404, 'Object does not exist.')
def dbg(self, *args):
......@@ -92,8 +93,8 @@ class DirectSvc(object):
return x
def error(self):
raise HTTP(404, 'Object does not exist.')
def error(self, code, message):
raise HTTP(code, message)
def get_api(self):
......@@ -165,13 +166,17 @@ class DirectSvc(object):
li = []
for arg in transactions:
di = dict(arg)
self.dbg('transaction:', di)
try:
k = proc_key(arg['action'], arg['method'])
di['result'] = self.procedures[k](*arg['data'])
if arg['data']:
di['result'] = self.procedures[k](*arg['data'])
else:
di['result'] = self.procedures[k]()
except Exception:
except Exception, e:
traceback.print_exc(file=sys.stdout)
raise HTTP(500, 'Error on the server')
self.error(500, 'Internal server error.')
del di['data']
li.append(di)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment