This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-12-21
Channels
- # beginners (201)
- # boot (125)
- # cider (3)
- # cljs-dev (21)
- # cljsrn (165)
- # clojars (8)
- # clojure (332)
- # clojure-belgium (1)
- # clojure-gamedev (8)
- # clojure-russia (75)
- # clojure-spec (25)
- # clojure-uk (96)
- # clojurebridge (2)
- # clojurescript (130)
- # code-reviews (16)
- # cursive (26)
- # datomic (20)
- # devops (6)
- # emacs (6)
- # hoplon (90)
- # jobs (9)
- # luminus (2)
- # off-topic (4)
- # om (65)
- # onyx (5)
- # pedestal (4)
- # protorepl (6)
- # re-frame (34)
- # reagent (12)
- # ring (4)
- # ring-swagger (7)
- # specter (2)
- # test-check (8)
- # untangled (2)
- # vim (1)
- # yada (6)
Hi, im trying to add some exception monitoring,
since castra is catching all exceptions and does its own stuff to it i can not just use the JVM setDefaultUncaughtExceptionHandler
You think its ok if wrap-castra
has an optional exception-handler
option which has to take the exception as arg, and return the exception back (after you are done with your side effects)
i have on the frontend on-error
with mkremote
but at that time im already on the frontend and have to callback to the backend and also the exception is not in its original form anymore
actually it would be cool to also get fn-name and args.
maybe an on-error
on middleware and have something like
(catch Throwable e
(when on-error (on-error fn-name args e))
(response body-keys req {:error (ex->clj e)})
@peterromfeld: i just pushed off the quickfix i was using last night. https://github.com/jumblerg/castra/blob/master/src/castra/middleware.clj#L126
basically, i'm printing off the handled exceptions to stderr before they're returned back to the client.
this should cause them to appear in logs, etc. but i'm not certain this is the optimal approach.
any reason why hoplon doesn’t use the history functionality from google closure for route cells?
i’m not seeing my route cell updating in response to setting the window hash in phantomjs
but the bidi router did (based on goog)
do you happen to know, offhand, if the route cell works in other webkit implementations?
works fine in chrome
just tinkering now
i got a test that looks like
i believe webkit and chrome parted ways, chrome uses the blink fork now i think. but the route cell was implemented pre-blink probably.
(deftest ??handler?=
(let [h?= (handler?= :home)]
(navigate! :home)
(is @h?=)
(navigate! :privacy)
(is (not @h?=))))
passed with a bidi router but not with a route cell
i’ll give safari a shot
yeah, works in safari
i got a (j/cell= (prn route=))
i see the printout in chrome and safari
don’t even see it in tests
navigate!
is just a wrapper around bidi and
(defn set-hash!
[s]
{:pre [(string? s)]}
(-> js/window
.-location
.-hash
(set! s)))
actually @jumblerg it looks like there is a Html5 and regular Html version of the History management from google
https://github.com/google/closure-library/blob/master/closure/goog/history/history.js
looks like it has tons of browser support code to make navigation work
will use the Html5 pushstate api if available
btw @jumblerg printing stack trace by default is not a good option 🙂 Most serious deployments use a logger of some sort. You might also want to increment all kinds of stats so best to expose that via something like an on-error
callback
@dm3 well i think i have to do something to get it working, i’ll let you know how i go 🙂
@dm3: wouldn't exceptions written to *err*
be consequently handled by any logging framework?
this is not my area of expertise; i started into a deep dive on this yesterday, but cut myself short since i had to ship some code. this was a stopgap solution.
i think there's a with-logs
fn or something similar than will capture it, but i agree that @peterromfeld's approach is probably a better solution.
i suspect there's already a technique for doing this that i'm just not aware of; i find it hard to believe that this case isn't already covered somehow.
but it seemed like Castra just serialized all of the caught exceptions as a response and never gave a chance to do anything else with them, no?
yeah, the exception gets caught and passed up to the client wrapped in an http 200, where it is inflated back into an error.
this is handy in many cases, for example, authorization errors (404s), where you want the client to be able to handle the error by reverting to a login screen.
You can make a Middleware but still someone might want the original exception before castra dfl it
i would love to see a on-error
option on castra middleware, which calls fn-name/symbol + args + exception on this function 😄
@peterromfeld: it seems that something like this would be useful; will definitely make sure we get in right before merging into master. pull my branch and make a pr off of it if you like.
ok ill look into it tomorrow if i can come up with some elegant solution
i want to circle back with micha or alan and make sure i'm not missing anything first; there's likely some less obvious technique for doing this already i'm unaware of.
maybe some implicit and undocumented change to the environment that may cause certain classes of errors to propagate up into logs instead of being sent across the wire to the client when in production.
you can have a defaulthandler for uncaught exceptions.. but castra catches it 😉
that's not a great solution either - you should be able to access the inputs that caused the exception too
yup i also would like that too, more context better for debugging later
@dm3 this seems to work
(defn history-cell
[]
(let [c (j/cell nil)
history (History.)]
(j/with-let [_ (j/cell= c #(.setToken history %))]
(goog.events/listen history goog.History/EventType.NAVIGATE
(fn [e]
(reset! c (.-token e))))
(.setEnabled history true))))
it works a bit different to a route cell though
you reset it to navigate
and yep, that totally fixed my tests
@jumblerg @dm3 there must be some magic x-browser something in google history that route cell doesn’t have
because my phantomjs tests are passing now
we should like, send antirez a christmas bonus
i bet james is down
@chopmo: welcome!
Thanks @flyboarder !