juxt / yada

A powerful Clojure web library, full HTTP, full async - see https://juxt.pro/yada/index.html
MIT License
735 stars 97 forks source link

handle a non-numeric status #295

Closed scarytom closed 5 years ago

scarytom commented 5 years ago

No idea where this error originated from, but got an annoying exception from our prod system:


  java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Number
    at clojure.lang.Numbers.lt(Numbers.java:226)
    at clojure.lang.Numbers.lt(Numbers.java:3841)
    at yada.handler$default_error_handler.invokeStatic(handler.clj:35)```

Clearly somehow we have an error whose `:status` is a `String`, which the default error handler barfs on. I'd rather have it treat this as an error and report it, so I can debug the system.
scarytom commented 5 years ago

I guess the proper fix for this issue is for yada to use a namespace qualified :status keyword, which I believe is best practice these days, but that is a bigger change that is also API breaking.

malcolmsparks commented 5 years ago

I'll accept the PR, as it's binary compatible.

Yes, it's probably worth thinking about a proper way of communicating status via a ex-info using namespaced keywords, e.g. yada/status.