我有一些用python烧写的代码,我有一个函数如下:
SELECT per.person_no,
perbus.person_no,
perbus.edit_dt,
perbus.org_name,
perbus.FIRST_NAME
FROM users.persons per
LEFT OUTER JOIN
(SELECT ASSOC.edit_dt,
PER_CONTACTS.PERSON_NO,
PER_CONTACTS.PERSON_ID AS PER_ID,
PER.EXTERNAL_PERSON_ID AS EXT_PER_ID,
PER_CONTACTS.LNAME
||', '
||PER_CONTACTS.FNAME AS NAME,
PER_CONTACTS.FNAME AS FIRST_NAME,
PER_CONTACTS.MNAME AS MIDDLE_NAME,
PER_CONTACTS.LNAME AS LAST_NAME,
ORG.ORG_NAME AS ORG_NAME,
T_ORG.ORG_ID AS ORG_ID,
T_ORG.ORG_DISPLAY_ID AS EXT_ORG_ID,
ROW_NUMBER() OVER(PARTITION BY PER_CONTACTS.PERSON_ID ORDER BY ASSOC.edit_dt DESC) rn
FROM USERS.PER_CONTACTS PER_CONTACTS
LEFT OUTER JOIN USERS.PERSONS PER
ON PER.PERSON_ID = PER_CONTACTS.PERSON_ID
LEFT OUTER JOIN USERS.ASSOC ASSOC
ON ASSOC.PERSON_ID = PER.PERSON_ID
LEFT OUTER JOIN USERS.T_ORG T_ORG
ON T_ORG.T_ORG_ID = ASSOC.T_ORG_ID
LEFT OUTER JOIN USERS.ORG ORG
ON ORG.ORG_ID = T_ORG.ORG_ID
WHERE PER_CONTACTS.CONTACT_ROLE_LOV = 'EMPLOYEE'
AND PER_CONTACTS.PERSON_NO IN
(SELECT PERSON_NO FROM USERS.QA_APPROVED
)
ORDER BY ASSOC.edit_dt DESC
) perbus ON perbus.PERSON_NO = PER.PERSON_NO
WHERE PER.PERSON_NO IN
(SELECT PERSON_NO FROM USERS.QA_APPROVED
)
AND perbus.rn = 1;
但是这条消息不足以为我提供足够的信息。我只想打印传递给errorhandler的异常的回溯。有没有办法做这个简单的事情?
答案 0 :(得分:2)
假设在sys
仍然可以使用异常和回溯时从上下文中调用错误处理程序,您应该可以使用traceback.format_exc
。
import traceback
@app.errorhandler(500)
def internal_error(exception):
print "500 error caught"
print traceback.format_exc()
答案 1 :(得分:0)
我认为你可以这样解决:
import sys
import traceback
@app.errorhandler(500)
def internal_error(exception):
print "500 error caught"
etype, value, tb = sys.exc_info()
print traceback.print_exception(etype, value, tb)
您可以打印回溯信息