# -*- coding: utf-8 -*-

from starlette.applications import Starlette
from starlette.exceptions import HTTPException
from starlette.responses import JSONResponse


async def http_exception_handler(request, e):
    return JSONResponse({'ok': False, 'message': e.detail}, status_code=e.status_code)


async def unhandled_exception_handler(request, e):
    return JSONResponse({'ok': False, 'message': type(e).__name__ + ": " + str(e)}, status_code=500)


class App(Starlette):
    def __init__(self):
        super().__init__()
        self.debug = True
        self.add_exception_handler(HTTPException, http_exception_handler)
        self.add_exception_handler(500, unhandled_exception_handler)

@@ -110,16 +110,55 @@
 ception%0A
+from starlette.requests import Request%0A
 from sta
@@ -228,35 +228,59 @@
 _handler(request
-, e
+: Request, e: HTTPException
 ):%0A    return JS
@@ -400,19 +400,39 @@
 (request
-, e
+: Request, e: Exception
 ):%0A    r
@@ -737,19 +737,25 @@
 handler(
-500
+Exception
 , unhand

Add type annotations to app module