Skip to content

Commit

Permalink
Add proper type overload to determine handle_exception return type
Browse files Browse the repository at this point in the history
  • Loading branch information
mvdbeek committed May 31, 2024
1 parent 90d1f13 commit 6909dcb
Showing 1 changed file with 48 additions and 2 deletions.
50 changes: 48 additions & 2 deletions lib/galaxy/web/framework/middleware/error.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from typing import (
cast,
Optional,
overload,
)

import markupsafe
Expand All @@ -28,6 +29,7 @@
formatter,
reporter,
)
from typing_extensions import Literal

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -191,7 +193,7 @@ def make_catching_iter(self, app_iter, environ, sr_checker):
return app_iter
return CatchingIter(app_iter, environ, sr_checker, self)

def exception_handler(self, exc_info, environ) -> Optional[str]:
def exception_handler(self, exc_info, environ) -> str:
simple_html_error = False
if self.xmlhttp_key:
get_vars = wsgilib.parse_querystring(environ)
Expand Down Expand Up @@ -348,10 +350,54 @@ def extraData(self):
}


@overload
def handle_exception(
exc_info,
error_stream,
html=True,
html: Literal[False] = ...,
debug_mode=...,
error_email=...,
error_log=...,
show_exceptions_in_wsgi_errors=...,
error_email_from=...,
smtp_server=...,
smtp_username=...,
smtp_password=...,
smtp_use_tls=...,
error_subject_prefix=...,
error_message=...,
simple_html_error=...,
environ=...,
) -> None:
...


@overload
def handle_exception(
exc_info,
error_stream,
html: Literal[True] = ...,
debug_mode=...,
error_email=...,
error_log=...,
show_exceptions_in_wsgi_errors=...,
error_email_from=...,
smtp_server=...,
smtp_username=...,
smtp_password=...,
smtp_use_tls=...,
error_subject_prefix=...,
error_message=...,
simple_html_error=...,
environ=...,
) -> str:
...


def handle_exception(
exc_info,
error_stream,
html: bool = True,
debug_mode=False,
error_email=None,
error_log=None,
Expand Down

0 comments on commit 6909dcb

Please sign in to comment.