July 2017
Intermediate to advanced
284 pages
6h 45m
English
To see how error-kit handles exceptions, we’ll create a simple application and perpetrate some errors. Let’s write an app that parses log file entries. Our log file entries will look like this:
| | 2008-10-05 12:14:00 WARN Some warning message here... |
In this imperfect world, it is inevitable that some miscreant will pass bad data to the log file parser. To deal with this, we will define an error:
| | (use 'clojure.contrib.error-kit) |
| | (deferror malformed-log-entry [] [msg] |
| | {:msg msg |
| | :unhandled (throw-msg IllegalArgumentException)}) |
The error takes a single argument, a msg describing the problem. The :unhandled value defers to a normal Clojure (Java) exception in the event that a caller chooses not to handle the error. (The ...
Read now
Unlock full access