diff --git a/docs/de/docs/tutorial/handling-errors.md b/docs/de/docs/tutorial/handling-errors.md index 2802653d2..732ac03f3 100644 --- a/docs/de/docs/tutorial/handling-errors.md +++ b/docs/de/docs/tutorial/handling-errors.md @@ -19,58 +19,6 @@ Die Statuscodes im 400er-Bereich bedeuten hingegen, dass es einen Fehler gab. Erinnern Sie sich an all diese **404 Not Found** Fehler (und Witze)? -## Fehlerüberwachungstools - -Sentry ist ein Anwendungsüberwachungsdienst, der Entwicklern hilft, Probleme in Echtzeit zu identifizieren und zu beheben. Sentry bietet: - -* Fehlergruppierung zur Aggregation ähnlicher Fehler -* Quellcode-Kontext aus Stack-Traces -* Detaillierte Anfrageinformationen -* Leistungsüberwachung für Webanfragen, Datenbankabfragen und mehr -* Verteiltes Tracing, um zu verstehen, wie sich Fehler über den Stack ausbreiten - -Um Sentry mit FastAPI zu verwenden, installieren Sie zuerst das SDK: - -```bash -pip install --upgrade 'sentry-sdk[fastapi]' -``` - -Initialisieren Sie dann Sentry in Ihrer Anwendung: - -```python -import sentry_sdk -from fastapi import FastAPI - -sentry_sdk.init( - dsn="your-dsn-here", - # Setzen Sie traces_sample_rate, um den Prozentsatz der an Sentry zu sendenden Traces zu konfigurieren, wobei 1.0 100% entspricht - traces_sample_rate=1.0, -) - -app = FastAPI() - -# Ihr FastAPI-Code hier -``` - -Sentry erfasst automatisch unbehandelte Ausnahmen, aber Sie können auch explizit Ausnahmen erfassen und benutzerdefinierte Events senden: - -```python -@app.get("/items/{item_id}") -async def read_item(item_id: int): - try: - # Ihr Code, der fehlschlagen könnte - if item_id == 0: - raise ValueError("Item ID kann nicht Null sein") - # ... - except Exception as e: - # Erfassen Sie die Ausnahme - sentry_sdk.capture_exception(e) - # Sie können die Ausnahme weiterhin normal behandeln - raise HTTPException(status_code=500, detail="Interner Serverfehler") -``` - -Weitere Informationen finden Sie in der Sentry FastAPI-Integrationsdokumentation. - ## `HTTPException` verwenden Um HTTP-Responses mit Fehlern zum Client zurückzugeben, verwenden Sie `HTTPException`. diff --git a/docs/es/docs/tutorial/handling-errors.md b/docs/es/docs/tutorial/handling-errors.md index cba67f93f..2e4464989 100644 --- a/docs/es/docs/tutorial/handling-errors.md +++ b/docs/es/docs/tutorial/handling-errors.md @@ -19,58 +19,6 @@ Los códigos de estado en el rango de 400 significan que hubo un error por parte ¿Recuerdas todos esos errores de **"404 Not Found"** (y chistes)? -## Herramientas de Monitoreo de Errores - -Sentry es un servicio de monitoreo de aplicaciones que ayuda a los desarrolladores a identificar y solucionar problemas en tiempo real. Sentry proporciona: - -* Agrupación de errores para agregar errores similares -* Contexto del código fuente de los rastros de pila -* Información detallada de las solicitudes -* Monitoreo de rendimiento para solicitudes web, consultas de bases de datos y más -* Rastreo distribuido para entender cómo se propagan los errores a través de su stack - -Para usar Sentry con FastAPI, primero instale el SDK: - -```bash -pip install --upgrade 'sentry-sdk[fastapi]' -``` - -Luego inicialice Sentry en su aplicación: - -```python -import sentry_sdk -from fastapi import FastAPI - -sentry_sdk.init( - dsn="your-dsn-here", - # Configure traces_sample_rate para establecer el porcentaje de trazas a enviar a Sentry, donde 1.0 es 100% - traces_sample_rate=1.0, -) - -app = FastAPI() - -# Su código FastAPI aquí -``` - -Sentry capturará automáticamente las excepciones no manejadas, pero también puede capturar excepciones explícitamente y enviar eventos personalizados: - -```python -@app.get("/items/{item_id}") -async def read_item(item_id: int): - try: - # Su código que podría fallar - if item_id == 0: - raise ValueError("El ID del ítem no puede ser cero") - # ... - except Exception as e: - # Capture la excepción - sentry_sdk.capture_exception(e) - # Aún puede manejar la excepción normalmente - raise HTTPException(status_code=500, detail="Error interno del servidor") -``` - -Para más información, consulte la documentación de integración de Sentry para FastAPI. - ## Usa `HTTPException` Para devolver responses HTTP con errores al cliente, usa `HTTPException`.