We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hi. Instead of using callbacks in handlers/middlewares I prefer to use promises.
The reason is that if I (or somebody else) forget to handle some error - I can still set some handling and return 500 instead of waiting for timeout.
500
Currently I am using this middleware to take care of unexpected errors in my handlers:
(ns app.routes.middleware.rejection (:require [taoensso.timbre :as timbre])) (defn wrap-rejection "Middleware returns `500` if handler returned rejected promise and logs the error." [handler] (fn [req res raise] (let [result (handler req res raise)] (when (instance? js/Promise result) (.catch result (fn [e] (timbre/error e "Rejection middleware caught error") (res {:status 500})))))))
Would you accept possible prs that would convert callbacks into promises like
macchiato-core/src/macchiato/middleware/restful_format.cljs
Line 129 in f21bddc
The text was updated successfully, but these errors were encountered:
Hi, yeah I agree that promises are easier to work with and a PR would be very welcome.
Sorry, something went wrong.
No branches or pull requests
Hi. Instead of using callbacks in handlers/middlewares I prefer to use promises.
The reason is that if I (or somebody else) forget to handle some error - I can still set some handling and return
500
instead of waiting for timeout.Currently I am using this middleware to take care of unexpected errors in my handlers:
Would you accept possible prs that would convert callbacks into promises like
macchiato-core/src/macchiato/middleware/restful_format.cljs
Line 129 in f21bddc
The text was updated successfully, but these errors were encountered: