As I understand it, pre and post conditions are there to support
contracts-based programming. Violating a contract should be considered as
bad as having a compile-time error.

So, as I see it, no, they are not meant for "basic validations", they are
meant for strictly enforced rules. If your contracts are not met, your
software is wrong. Exceptions are for writing code that is correct under
exceptional circumstances. These are orthogonal concerns, hence the Error
type.

(This is just how I see it; I have no authority on the subject.)

On Friday, December 7, 2012, Jason Bennett wrote:

> I hate to resurrect a dead thread, but I've been dealing with the same
> problem.
>
> Pre/postconditions throw an Error, not an exception, meaning you have to
> catch Throwable instead. This would violate most all good practice in
> Java/JVM programming. Are pre/postconditions just not designed for basic
> validation like nil handling, or should we consider Throwable to be the
> root of Clojure exceptions?
>
> jason
>
> On Wednesday, March 21, 2012 4:06:11 PM UTC-7, Sean Corfield wrote:
>>
>> On Wed, Mar 21, 2012 at 9:34 AM, ron peterson <peterso...@gmail.com>
>> wrote:
>> > So I'd like to log the AssertionError using clojure.tools.logging
>> > library. For example if my function throws the following:
>> > #<AssertionError java.lang.AssertionError: Assert failed: (=
>> > "resource" s)>
>> >
>> > How do I "redirect it" to be printed in the console using the
>> > clojure.tools.logging library?
>>
>> Wrap the call in try/catch and log the exception in the catch.
>>
>> Exceptions are meant to bubble up to whatever can handle them.
>> --
>> Sean A Corfield -- (904) 302-SEAN
>> An Architect's View -- http://corfield.org/
>> World Singles, LLC. -- http://worldsingles.com/
>>
>> "Perfection is the enemy of the good."
>> -- Gustave Flaubert, French realist novelist (1821-1880)
>>
>>  --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to 
> clojure@googlegroups.com<javascript:_e({}, 'cvml', 
> 'clojure@googlegroups.com');>
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com <javascript:_e({}, 'cvml',
> 'clojure%2bunsubscr...@googlegroups.com');>
> 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 post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to