-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
server-test-host: Rethrown exception in StatusPages exception handler fails test #1701
Comments
This is by design behaviour: uncaught exceptions are always treated as errors and should not occur. |
Okay that makes sense. Perhaps a note should be added to the documentation about that. |
As good as it sounds, that doesn't help us testing. For now I plan to add wrap each lambda I give to routing into try-catch, but that's obviously a hack. |
Hi @cab404, to do that you can add the pipeline interceptor and wrap the |
Just encountered this myself, and found that you can also get around it by just logging the exception manually, rather than re-throwing it:
|
Ktor Version and Engine Used (client or server and name)
Using ktor server 1.3.1, with
ktor-server-test-host
Describe the bug
When using the
StatusPages
feature to handle exceptions, a rethrowing the exception will bubble out to the test and cause a failure even if it was successfully handled with acall.respond
. Rethrowing exceptions is suggested as a way to log caught exceptions in the documentation: https://ktor.io/servers/features/status-pages.html#logging-exceptionsTo Reproduce
Expected behavior
I expect the above test to pass, and the exception to be logged as it would in a non-test application
The text was updated successfully, but these errors were encountered: