Handle exceptions in stored procedures
This commit is contained in:
parent
5d1b5f90ac
commit
144fdbefb1
1 changed files with 22 additions and 3 deletions
|
|
@ -131,7 +131,11 @@ class OrderHead(StoredProcedure):
|
|||
# self['OrderNumber'] = pymssql.output(int)
|
||||
|
||||
def callproc(self):
|
||||
try:
|
||||
super(OrderHead, self).callproc()
|
||||
except pymssql.DatabaseError:
|
||||
logger.error("A DatabaseException has been caught. Order could not be created..")
|
||||
|
||||
# If call succeeded, then order is allowed to be invoiced.
|
||||
return self['o_OrderNumber'], bool(self['c_webUserName'])
|
||||
|
||||
|
|
@ -189,7 +193,10 @@ class OrderRow(StoredProcedure):
|
|||
# self['o_AllocatedDate'] = pymssql.output(str)
|
||||
|
||||
def callproc(self):
|
||||
try:
|
||||
super(OrderRow, self).callproc()
|
||||
except pymssql.DatabaseError:
|
||||
logger.error("A DatabaseException has been caught. Order row not created.")
|
||||
return self['o_OrderRow']
|
||||
|
||||
|
||||
|
|
@ -232,6 +239,13 @@ class PlaceOrder(StoredProcedure):
|
|||
self['c_orderStatus'] = None
|
||||
self['c_ProvinceCode'] = None # For US customers etc.
|
||||
|
||||
def callproc(self):
|
||||
try:
|
||||
return super(PlaceOrder, self).callproc()
|
||||
except pymssql.DatabaseError:
|
||||
logger.error("A DatabaseException has been caught. Order %d not updated." %
|
||||
(self['c_OrderNumber']))
|
||||
|
||||
|
||||
class NotifyInfo(StoredProcedure):
|
||||
"""Mapping for the JAPP_spr_LogTrade_Get_NotifyInfo stored procedure parameters
|
||||
|
|
@ -245,9 +259,14 @@ class NotifyInfo(StoredProcedure):
|
|||
self['c_ForetagKod'] = 1 # Hardcoded to LK
|
||||
|
||||
def callproc(self):
|
||||
result = super(NotifyInfo, self).callproc(resultset=True)
|
||||
ret = {'email': None, 'sms': None, 'phone': None}
|
||||
|
||||
try:
|
||||
result = super(NotifyInfo, self).callproc(resultset=True)
|
||||
except pymssql.DatabaseError:
|
||||
logger.error("A DatabaseException has been caught. NotifyInfo not fetched.")
|
||||
return ret
|
||||
|
||||
if isinstance(result, list):
|
||||
for r in result:
|
||||
if r[1][7:].lower() in ret:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue