How to prevent the server from sending the stacktrace?

hi everyone
How can I prevent the display of stacktrace in server responses and not have the following response?

HTTP 404 Not Found - WebApplicationException (SessionResource:117 < ...)
Anton Tananaeva year ago

We don't have any configuration option for it, but you can easily change it in the code.

Thank you