Search Options

Results per page
Sort
Preferred Languages
Advance

Results 11 - 20 of 101 for exceptions (0.16 sec)

  1. docs/em/docs/tutorial/handling-errors.md

    ```
    
    ## โŽ ๐Ÿ›ƒ โš  ๐Ÿ•โ€๐Ÿฆบ
    
    ๐Ÿ‘† ๐Ÿ’ช ๐Ÿšฎ ๐Ÿ›ƒ โš  ๐Ÿ•โ€๐Ÿฆบ โฎ๏ธ <a href="https://www.starlette.io/exceptions/" class="external-link" target="_blank">๐ŸŽ โš  ๐Ÿš™ โšช๏ธโžก๏ธ ๐Ÿ’ƒ</a>.
    
    โžก๏ธ ๐Ÿ’ฌ ๐Ÿ‘† โœ”๏ธ ๐Ÿ›ƒ โš  `UnicornException` ๐Ÿ‘ˆ ๐Ÿ‘† (โš–๏ธ ๐Ÿ—ƒ ๐Ÿ‘† โš™๏ธ) ๐Ÿ’ช `raise`.
    
    &amp; ๐Ÿ‘† ๐Ÿ’š ๐Ÿต ๐Ÿ‘‰ โš  ๐ŸŒ โฎ๏ธ FastAPI.
    
    ๐Ÿ‘† ๐Ÿ’ช ๐Ÿšฎ ๐Ÿ›ƒ โš  ๐Ÿ•โ€๐Ÿฆบ โฎ๏ธ `@app.exception_handler()`:
    
    ```Python hl_lines="5-7  13-18  24"
    {!../../../docs_src/handling_errors/tutorial003.py!}
    ```
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Fri Mar 22 01:42:11 GMT 2024
    - 8.3K bytes
    - Viewed (0)
  2. docs_src/custom_request_and_route/tutorial002.py

    from typing import Callable, List
    
    from fastapi import Body, FastAPI, HTTPException, Request, Response
    from fastapi.exceptions import RequestValidationError
    from fastapi.routing import APIRoute
    
    
    class ValidationErrorLoggingRoute(APIRoute):
        def get_route_handler(self) -> Callable:
            original_route_handler = super().get_route_handler()
    
            async def custom_route_handler(request: Request) -> Response:
                try:
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Fri May 13 23:38:22 GMT 2022
    - 932 bytes
    - Viewed (0)
  3. tests/test_exception_handlers.py

        return JSONResponse(status_code=500, content={"exception": "server-error"})
    
    
    app = FastAPI(
        exception_handlers={
            HTTPException: http_exception_handler,
            RequestValidationError: request_validation_exception_handler,
            Exception: server_error_exception_handler,
        }
    )
    
    client = TestClient(app)
    
    
    @app.get("/http-exception")
    def route_with_http_exception():
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Feb 17 12:40:12 GMT 2022
    - 1.9K bytes
    - Viewed (0)
  4. fastapi/exception_handlers.py

    from fastapi.encoders import jsonable_encoder
    from fastapi.exceptions import RequestValidationError, WebSocketRequestValidationError
    from fastapi.utils import is_body_allowed_for_status_code
    from fastapi.websockets import WebSocket
    from starlette.exceptions import HTTPException
    from starlette.requests import Request
    from starlette.responses import JSONResponse, Response
    from starlette.status import HTTP_422_UNPROCESSABLE_ENTITY, WS_1008_POLICY_VIOLATION
    
    
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Sun Jun 11 19:08:14 GMT 2023
    - 1.3K bytes
    - Viewed (0)
  5. tests/test_tutorial/test_dependencies/test_tutorial008d.py

        )
    
    
    def test_internal_server_error():
        from docs_src.dependencies.tutorial008d import app
    
        client = TestClient(app, raise_server_exceptions=False)
        response = client.get("/items/portal-gun")
        assert response.status_code == 500, response.text
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Sat Feb 24 23:06:37 GMT 2024
    - 1.2K bytes
    - Viewed (0)
  6. tests/test_starlette_exception.py

            )
        return {"item": items[item_id]}
    
    
    @app.get("/http-no-body-statuscode-exception")
    async def no_body_status_code_exception():
        raise HTTPException(status_code=204)
    
    
    @app.get("/http-no-body-statuscode-with-detail-exception")
    async def no_body_status_code_with_detail_exception():
        raise HTTPException(status_code=204, detail="I should just disappear!")
    
    
    @app.get("/starlette-items/{item_id}")
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Fri Jun 30 18:25:16 GMT 2023
    - 7.4K bytes
    - Viewed (0)
  7. docs/ja/docs/tutorial/handling-errors.md

    ```
    
    ## ใ‚ซใ‚นใ‚ฟใƒ ไพ‹ๅค–ใƒใƒณใƒ‰ใƒฉใฎใ‚คใƒณใ‚นใƒˆใƒผใƒซ
    
    ใ‚ซใ‚นใ‚ฟใƒ ไพ‹ๅค–ใƒใƒณใƒ‰ใƒฉใฏ<a href="https://www.starlette.io/exceptions/" class="external-link" target="_blank">StarletteใจๅŒใ˜ไพ‹ๅค–ใƒฆใƒผใƒ†ใ‚ฃใƒชใƒ†ใ‚ฃ</a>ใ‚’ไฝฟ็”จใ—ใฆ่ฟฝๅŠ ใ™ใ‚‹ใ“ใจใŒใงใใพใ™ใ€‚
    
    ใ‚ใชใŸ๏ผˆใพใŸใฏไฝฟ็”จใ—ใฆใ„ใ‚‹ใƒฉใ‚คใƒ–ใƒฉใƒช๏ผ‰ใŒ`raise`ใ™ใ‚‹ใ‹ใ‚‚ใ—ใ‚Œใชใ„ใ‚ซใ‚นใ‚ฟใƒ ไพ‹ๅค–`UnicornException`ใŒใ‚ใ‚‹ใจใ—ใพใ—ใ‚‡ใ†ใ€‚
    
    ใใ—ใฆใ€ใ“ใฎไพ‹ๅค–ใ‚’FastAPIใงใ‚ฐใƒญใƒผใƒใƒซใซๅ‡ฆ็†ใ—ใŸใ„ใจๆ€ใ„ใพใ™ใ€‚
    
    ใ‚ซใ‚นใ‚ฟใƒ ไพ‹ๅค–ใƒใƒณใƒ‰ใƒฉใ‚’`@app.exception_handler()`ใง่ฟฝๅŠ ใ™ใ‚‹ใ“ใจใŒใงใใพใ™:
    
    ```Python hl_lines="5 6 7  13 14 15 16 17 18  24"
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Fri Mar 22 01:42:11 GMT 2024
    - 11.8K bytes
    - Viewed (0)
  8. docs_src/handling_errors/tutorial004.py

    from fastapi.exceptions import RequestValidationError
    from fastapi.responses import PlainTextResponse
    from starlette.exceptions import HTTPException as StarletteHTTPException
    
    app = FastAPI()
    
    
    @app.exception_handler(StarletteHTTPException)
    async def http_exception_handler(request, exc):
        return PlainTextResponse(str(exc.detail), status_code=exc.status_code)
    
    
    @app.exception_handler(RequestValidationError)
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Mar 26 19:09:53 GMT 2020
    - 762 bytes
    - Viewed (0)
  9. fastapi/utils.py

                    "alias": alias,
                }
            )
        try:
            return ModelField(**kwargs)  # type: ignore[arg-type]
        except (RuntimeError, PydanticSchemaGenerationError):
            raise fastapi.exceptions.FastAPIError(
                "Invalid args for response field! Hint: "
                f"check that {type_} is a valid Pydantic field type. "
                "If you are using a return type annotation that is not a valid Pydantic "
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Apr 18 19:40:57 GMT 2024
    - 7.8K bytes
    - Viewed (0)
  10. fastapi/security/http.py

    import binascii
    from base64 import b64decode
    from typing import Optional
    
    from fastapi.exceptions import HTTPException
    from fastapi.openapi.models import HTTPBase as HTTPBaseModel
    from fastapi.openapi.models import HTTPBearer as HTTPBearerModel
    from fastapi.security.base import SecurityBase
    from fastapi.security.utils import get_authorization_scheme_param
    from pydantic import BaseModel
    from starlette.requests import Request
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Fri Apr 19 15:29:38 GMT 2024
    - 13.2K bytes
    - Viewed (0)
Back to top