Error formatting macro: pagetree: java.lang.NullPointerException
Skip to end of metadata
Go to start of metadata
You are viewing an old version of this page. View the current version. Compare with Current  |   View Page History

The Problem

I want deeply detailed information about exceptions, as a generic facility. The information should be useful for programmatic and human consumption.

Assumptions / Constraints

  • Integrate well with platform
  • Work ok for interop callers
  • Exceptions are not for flow control

Phase One

Provide built-in Clojure exception types that are richer than Java exceptions, and eliminate the need for app developers to gen-class their own exception types. Since some information is costly to provide, provide a *debug* flag that allows the costly stuff to be disabled in production.

Debug Builds

  • the following group of features will be enabled when *debug* is set
    • assert
    • *unchecked-math* math becomes checked math
      • explicit unchecked does not change (might be for semantic reasons)
    • include locals (and bindings ??) in all thrown errors (or in assertions if this is too hard)
      • is conditional in throw path too expensive?
      • otherwise compile throw differently based on flag
  • unify with Java assertions?
  • Need separate assert-like constructs that never get turned off
    • typical name: verify
    • for preconditions: prefix either verify- or assert- to :pre and :post ??
      • what is the default ??

Errors as Data

Provide built-in types than extend Throwable and implement IPersistentMap. Goal: The new types are capable enough that Clojure programmers can be out of the business of making new Throwable subclasses.

  • expose error info as part of the map
  • clojure owns unnamespaced keywords
  • include :namespace key
    • will be a great match target, alleviate one want for typed exceptions
  • no need to include :fn key
    • not a good match target
    • available for human consumption in context of stacktrace
  • need a few different types
    • error, runtimeexception, assertion?
  • need names
    • unworkable: Clojure, PersistentMap,
    • maybe: Condition (but don't want to suggest non-error flow control)
  • provide fn that parses Java exceptions into similar maps
    • e.g. clj-stacktrace
  • REPL exception help works in terms of maps, not Java exceptions