Skip to content

0.4.0

Choose a tag to compare

@junah201 junah201 released this 04 Feb 00:57
· 40 commits to main since this release
918d88d

Highlight

Error handling

Now, you can add your custom error handler, like this:

from nexify import Nexify

class YourCustomException(Exception):
    pass

def custom_exception_handler(event, context, e):
    return {"statusCode": 400, "body": str(e)}

app = Nexify(exception_handlers={YourCustomException: custom_exception_handler})

Also, Nexify have default handler for HTTPException, RequestValidationError, ResponseValidationError.

app = Nexify()

@app.get("/items/{id}")
def read_item(id: Annotated[int, Path()]): ...

For example, if you sent a request to items/foo, you would receive a response like this:

{
    "detail": [
        {
            "type": "int_parsing",
            "loc": ["path", "id"],
            "msg": "Input should be a valid integer, unable to parse string as an integer",
            "input": "foo",
        }
    ]
}

Features

Fixes

Docs

  • 📝 Add introductory materials and first-steps tutorial. Commit 9183cd0 by @junah201