alex-oleshkevich / starception

Beautiful exception page for Starlette apps.
MIT License
96 stars 6 forks source link

AttributeError: 'NoneType' object has no attribute '__name__' #11

Closed euri10 closed 1 year ago

euri10 commented 1 year ago

minmal reproducible example below

import json
import typing

import uvicorn
from asyncpg.pgproto.pgproto import UUID
from starlette.applications import Starlette
from starlette.middleware import Middleware
from starlette.requests import Request
from starlette.routing import Route

from starception import StarceptionMiddleware

class WithHintError(Exception):
    solution = (
        'The connection to the database cannot be established. '
        'Either the database server is down or connection credentials are invalid.'
    )

def index_view(request: Request) -> typing.NoReturn:
    uuid_dict = {"id": UUID('a4ccb480-e020-4f90-8951-ff859f731b40') }
    json.dumps(uuid_dict)

def hint_view(request: Request) -> typing.NoReturn:
    raise WithHintError('Oops, something really went wrong...')

app = Starlette(
    debug=True,
    routes=[Route('/', index_view), Route('/hint', hint_view)],
    middleware=[Middleware(StarceptionMiddleware)],
)

if __name__ == '__main__':
    uvicorn.run("starlette_app:app")