Skip to content

Enhancement: Automatically document exceptions #2416

@floxay

Description

@floxay

Summary

Look for litestar.HttpException exceptions in the code (+ in guards & middlewares applied?) of route handlers and add them to raises (or somewhere else), similarly what https://github.com/Kludex/fastapi-responses does.

Basic Example

from litestar import Litestar, get
from litestar.exceptions import PermissionDeniedException

@get(sync_to_thread=False)
def test(force_perm_fail: bool = False) -> None:
    if force_perm_fail:
        raise PermissionDeniedException

app = Litestar([test])

image

Drawbacks and Impact

No response

Unresolved questions

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    EnhancementThis is a new feature or requestHelp Wanted 🆘This is good for people to work on

    Type

    No type

    Projects

    Status

    Ideas

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions