Coroutines in Controllers and Exception Handling #10784
Unanswered
srinunagulapalli
asked this question in
General
Replies: 1 comment
-
In general, suspend methods are handled exactly like reactive methods. So if a controller suspends and then throws an exception (like you seem to describe), that exception will be handled as if the controller returned a |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
In our micronaut-kotlin project, we are making the controller endpoints suspendable by using the
suspend
keyword and are executing the code inside the controller endpoint by starting acoroutineScope
like below:We are not throwing exceptions anywhere down the line in the application and using Arrow's
Either
to wrap any errors/exceptions. When the execution reaches back the controller, what happens if we unwrap this exception from theEither
and throw the exception in the controller?coroutineScope
is used in controller endpoint? will it launch a coroutine under the hood?@Error(global = true)
handle gracefully and catch immediately if an exception is thrown from a controller endpoint?Beta Was this translation helpful? Give feedback.
All reactions