;; I often find that the default behaviour of exceptions in emacs/slime is a bit ;; annoying. ;; Up pops up a debugger window, but that moves the focus away from where ;; you're working, and the new window then needs dismissing, and has often ;; buggered up the size of other windows, etc... ;; Also when playing with experimental clojure versions, the behaviour is a bit ;; random, and often the expression just gets swallowed, with no clue as to what ;; it was: ;; Anyway I wrote this little macro, which turns an exception into a return value: (defmacro tryc[ & e] `(try ~@e (catch Exception a# a#))) (tryc (java.io.File ".")) ;; #<ClassCastException java.lang.ClassCastException: java.lang.Class cannot be cast to clojure.lang.IFn> ;; Obviously you should only use this at the top level! ;; I find I'm using it all the time when writing code in emacs
Blog Archive
-
▼
2011
(26)
-
►
May
(7)
- Numerical Integration: Better Refinements?
- Numerical Integration: Better Refinements?
- Numerical Integration: Better Rules?
- Numerical Integration: Harder Functions
- Numerical Integration: Better Approximations
- Numerical Integration: What is an Integral?
- Clojure Inference (reduce, cl-format, Poisson dist...
-
▼
January
(10)
- Turning Exceptions into Return Values
- Finding Something in a Vector, Parsing CSV Files
- £500 if you can find me a job (version 1.0)
- K-means : An Algorithm for Clustering Data
- Cleaning Old Definitions from the REPL : shred-use...
- take-while-unstable
- A Very Gentle Introduction to Information Theory: ...
- A Very Gentle Introduction to Information Theory: ...
- A Very Gentle Introduction to Information Theory :...
- A Very Gentle Introduction to Information Theory :...
-
►
May
(7)
-
►
2010
(44)
-
►
October
(7)
- Gis A Job! (And I'll give you £500)
- EMACS Clojure Colour Scheme
- Generating XML to make SVG vector graphics files
- Latest Collection of Filthy Hacks for REPL Conditi...
- Cambridge Clojure Meetup (Tuesday 5th October in t...
- Polyglot Maven with Clojure and Emacs : My Edge is...
- Clojure Leiningen Setup for either EMACS or REPL
-
►
September
(15)
- Clojure 1.3 : First Impression : Clojure vs Scala ...
- Clojure 1.3 alpha release : A pom.xml to try it ou...
- Macros and Type Hints: Metadata and the Medusa.
- Clojure Faster than Machine Code?
- Graphics like it's 1979: How to get clojure to act...
- An Astonishing Macro of Narayan Singhal
- Clojure Swank Server is Insecure by Default : Use ...
- Clojure is Fast
- Clojure Macro Tutorial (Part III: Syntax Quote)
- Clojure Macro Tutorial (Part II: The Compiler Stri...
-
►
October
(7)
Sunday, January 30, 2011
Turning Exceptions into Return Values
Subscribe to:
Post Comments (Atom)

1 comments: