FastAPI अपवाद उठाकर त्रुटियों को संभालता है जिन्हें वह उचित HTTP प्रतिक्रियाओं में परिवर्तित करता है। HTTPException अधिकांश मामलों को शामिल करता है; कस्टम अपवाद हैंडलर आपको त्रुटि स्वरूप को विश्व स्तर पर नियंत्रित करने देते हैं।
HTTPException उठाना
fastapi HTTPException
():
item = db.get()
item:
HTTPException(status_code=, detail=)
item.is_public:
HTTPException(status_code=, detail=)
item
