Hi All,
I've updated the library from 0.1.5 version with new features:
- handlers now can branch depending on exception data
(on :error [data]
(if (> data 5)
(escalate :too-big)
(continue data)))
- a additional `fail` handler for short-circuiting default behaviour
- a
strategies<https://github.com/zcaudate/ribol/blob/master/test/ribol/test_ribol_strategies.clj>
document that show different ways of controlling program flow beyond
try/catch
--
I'd love for some feedback.
Chris
_________________
ribol
ribol is a conditional restart library for clojure inspired by errorkit,
having a more readable syntax, and designed with the base
clojure.lang.ExceptionInfo type in mind.
<https://github.com/zcaudate/ribol#installation>Installation:
In project.clj, add to dependencies:
[im.chit/ribol "0.2.1"]
<https://github.com/zcaudate/ribol#introduction>Introduction
ribol provides a conditional restart system. It can also be thought of as
an issue resolution system ortry++/catch++. The library provides an
alternative channel for resolving 'issues' (we use 'issues' here to
differentiate from 'exceptions', although they are pretty much the same
thing). It models a management structure, in which issues are reported to
management, who then what course of action to take depending upon the issue
and their own level of expertise:
-
When circumstances arise that need the attention of higher level
processes, an 'issue' would be raised that can be managed by any higher
level process.
-
An issue must have data as well as additional information attached:
- options that can be taken to resolve the issue
- a default option if there is no management intervention.
-
Issues are managed through handlers that check for the nature of the
issue and come up with the proper resolution process. There are six ways
that a manager can deal with a raised issue:
- directly (same as try/catch)
- using continue to keep going with a specified value
- using choose to specify an option
- using escalate to notify higher level managers
- using default to allow the issue to resolve itself
- using fail to throw an exception
Using these six different different issue resolution commands, a programmer
has the richness of language beyond the simple 'try/catch' statement at
his/her command to be able to craft very complex process control flow
strategies without mixing logic handling code in the middle tier. It can
also create new ways of thinking about the problem beyond the standard
throw/catch mechanism and offer more elegant ways to build programs.
Apart from the tutorial, interested users can peruse the
strategies<https://github.com/zcaudate/ribol/blob/master/test/ribol/test_ribol_strategies.clj>
document
(still a work in progress) to go through common restart strategies.
<https://github.com/zcaudate/ribol#other-libraries>Other Libraries
There are three other conditional restart libraries for clojure -
errorkit<https://github.com/richhickey/clojure-contrib/blob/master/src/main/clojure/clojure/contrib/error_kit.clj>
, swell <https://github.com/hugoduncan/swell> and
conditions<https://github.com/bwo/conditions>
-
errorkit provided the guiding architecture for ribol. However, ribol
updates errorkit with more options for controlling exceptions, uses
ex-info which is part of core and has an updated and more understandable
syntax.
-
swell and conditions are written to work with
slingshot<https://github.com/scgilardi/slingshot>
and try+/catch+.
<https://github.com/zcaudate/ribol#novel-features>Novel Features
- In addition to the other conditional restart Libraries, ribol offers
three more ways of handling error:escalate, fail and default. As of
version 0.2 of ribol, handlers are now much more flexible. As far as I
can tell, it is the only library that allows this type of resolution
switching (having an 'if' form in the 'on' handler to switch between
escalate and continue depending on the value of data:
(manage (manage
(mapv (fn [n]
(raise [:error {:data n}]))
[1 2 3 4 5 6 7 8])
(on :error [data]
(if (> data 5)
(escalate :too-big)
(continue data))))
(on :too-big [data]
(continue (- data))))
[1 2 3 4 5 -6 -7 -8])
- Additionally, the follow macros raise-on, raise-on-all and anticipate
offer
ways to hook into the java exceptions. Its use can be seen here: integer
division <https://github.com/zcaudate/ribol/wiki/Robust-Integer-Divide>
--
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.