पायथन 2.6.6 में, मैं अपवाद के त्रुटि संदेश को कैप्चर कैसे कर सकता हूं।पायथन: अपवाद का त्रुटि संदेश प्राप्त करना
आईई:
response_dict = {} # contains info to response under a django view.
try:
plan.save()
response_dict.update({'plan_id': plan.id})
except IntegrityError, e: #contains my own custom exception raising with custom messages.
response_dict.update({'error': e})
return HttpResponse(json.dumps(response_dict), mimetype="application/json")
यह does not काम करने लगते हैं। मुझे मिलता है:
IntegrityError('Conflicts are not allowed.',) is not JSON serializable
"यह does not काम करने के लिए लग रहे हैं।" - यह क्या करना चाहिए और क्या नहीं करता? – khachik
पाइथन का कौन सा संस्करण आप उपयोग कर रहे हैं? – infrared
हैलो, मैंने अपना प्रश्न अपडेट किया है। धन्यवाद – Hellnar