Clj-ex is a project mainly written in Clojure, it's free.
Simplest possible solution to the "exception problem" in clojure
The problem is this:
This project aims to be the absolute simplest possible solution to this problem.
(ns my.ns
(:import (clj_ex BasicException)))
(try
(throw (BasicException. {:anything ["whatever" "you" "want"]
:message "oops, it's borked!"}))
(catch BasicException e
(println e) ;; #<BasicException clj_ex.BasicException: oops, it's borked!>
(println (.data e)) ;; {:anything [whatever you want], :message oops, it's borked!}
))
That's all - just a subclass of Exception that:
data
method:message
(if supplied) as its message (returned from getMessage and used in toString)Other higher-level utilities, such as throw/catch macros with destructring, are deliberately omitted. This is just meant to be a building block.
Copyright (C) 2011 Chris Perkins
Distributed under the Eclipse Public License, the same as Clojure.