This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-06-27
Channels
- # bangalore-clj (2)
- # beginners (37)
- # boot (16)
- # cider (17)
- # clara (4)
- # cljs-dev (351)
- # cljsrn (16)
- # clojure (219)
- # clojure-belgium (4)
- # clojure-dev (3)
- # clojure-france (2)
- # clojure-italy (24)
- # clojure-russia (23)
- # clojure-spec (55)
- # clojure-switzerland (3)
- # clojure-uk (89)
- # clojurescript (121)
- # cursive (2)
- # datomic (29)
- # devops (2)
- # graphql (8)
- # hoplon (15)
- # immutant (5)
- # lein-figwheel (4)
- # liberator (3)
- # luminus (18)
- # off-topic (9)
- # om (6)
- # onyx (31)
- # pedestal (48)
- # precept (9)
- # re-frame (19)
- # reagent (63)
- # ring-swagger (69)
- # robots (1)
- # slack-help (14)
- # spacemacs (12)
- # sql (2)
- # test-check (4)
- # unrepl (28)
- # untangled (5)
- # yada (3)
As a design path, would there be good reason not to ultimately accept into the clojure trunk, a fork that wraps exceptions with a higher-level function or macro that provides some extra machinery? I was thinking of something like picking up exception text from a lookup table, rather than hardwiring it, this macro/function being able to do some extra things:
• lookup tables are swappable, so can be used for providing different messages for localization or adaptation to a certain audience.
• exceptions in development mode, can be served with a prompt or button, or default by configuration ― to report their text or suggest an improvement to a cloud server. it is kind of time that we use automated feedback and (big) data for improving our programming languages not only for our applications.
• equivalently, the former feature can be used to funnel exceptions from a class, to a group server for a tutor responding or reviewing them and similar social purposes. More importantly/usefully, this also allows one to funnel exceptions to monitor tools, in a clean integrated manner (maybe the macro/function can take a program-configuration-level fn
to perform exception side-effects).
Naively, the downsides I initially see are:
1. searching the internet for an exception will have to rely on an exception ID and version.
2. implied from (1) exception id's are then needed to convey unique error situations ― rather than their text.
3. anything left to Java to default on, will not be handled here ― e.g. you'd still get a null pointer exception when using a non-function var in call position.
4. some blogs, JIRA items, and books will gradually obsolete with regard to mentioning specific error text.
5. maybe the major undesirable side-effect: tools that already juggle exceptions ― namely various pretifiers, IDE integrations and other custom-made exception handling solutions ― will eventually need, or benefit from, being adapted, or API may need to support both the old and new language behavior for a while to ease their transition; On first thought, the new macro/function can cater for that compatibility though!
What other complications and downsides do you foresee here?
Many of the problematic exceptions, in terms of intelligibility, aren't just a question of a bad message, there's the much harder problem of the compiler or runtime code even knowing what really went wrong. See for example this classic:
user=> (into {} '[(:a 0) (:b 1)])
ClassCastException clojure.lang.Keyword cannot be cast to java.util.Map$Entry clojure.lang.ATransientMap.conj (ATransientMap.java:44)
- it's not just that the message is not helpful - the code throwing the exception doesn't have the right context to tell at the point it threw what you were actually trying to do.