Let’s assume I’ve a simple Web setup and I’m using Ring and Jetty close to their defaults. I have a handler that I give to Jetty. My understanding is that whatever is return from the handler should be sent by Jetty to client who made the Web request. I have also read that the final value in a Catch block is the value that will return.
Divide by zero to create an exception. I’m expecting to see the last form in the Catch block. And yet this does not work:
(defn handler [request]
(try
(/ 1 0)
(catch Exception e
(log/log e)
{:message "Error: our engineers are working to fix this."})
(finally
{:message "Error: our engineers are working to fix this."})))
If I run this locally, and I open Terminal, and I ping localhost:7001, which is the port I have this running on, then I get no response.
What do I need to do to return the value from the Catch or the Finally, when there is an Exception?