:pre and :post <http://blog.fogus.me/2009/12/21/clojures-pre-and-post/> are
great tools, but must be used at the very top of your function. You can
also use assert <http://clojuredocs.org/clojure_core/clojure.core/assert>,
at any location in your function. I've also had success with Prismatic's
Schema <https://github.com/Prismatic/schema>.


Hth

Tim Washington
Interruptsoftware.com <http://interruptsoftware.com>



On Sat, Dec 28, 2013 at 8:52 PM, larry google groups <
lawrencecloj...@gmail.com> wrote:

>
> > What still scars me in terms of incorporating Clojure as a language of
> choice in more
> > complicated projects I work on in my other life, is the error reporting
> facility. The
> > errors sometimes might as well just say 'I just cannot run!'.  It would
> be nice if
> > there was some facility to approximately point to some s-exp or line
> numbers.
>
> I agree that some of the stacktraces make it difficult to track down where
> an error is. I've lately dealt with that by writing a lot of :pre and :post
> assertions. That tends to narrow everything down very quickly. For
> instance:
>
> (defn get-count [request]
>   {:pre [
>          (= (type request) clojure.lang.PersistentHashMap)
>          (= (type (get-in request [:params :item-type])) java.lang.String)
>          ]
>    :post [
>           (= (type %) java.lang.Long)
>           (or (pos? %) (zero? %))
>           ]}
>   (monger/get-count (get-in request [:params :item-type])))
>
>
> At the top level of my app, I wrap everything in a try/catch and print out
> (clojure.stacktrace//print-stack-trace e). It's a bit of work, but once I
> wrote enough :pre and :post conditions they became sufficient to give me
> exact information about where any error occurred.
>
>
>
> On Friday, December 27, 2013 8:48:55 PM UTC-5, Guru Devanla wrote:
>
>> Seconded on Error reporting.
>>
>> I have been playing around with Clojure for sometime now and also
>> completed almost 150 of the 4clojure problems. What still scars me in terms
>> of incorporating Clojure as a language of choice in more complicated
>> projects I work on in my other life, is the error reporting facility. The
>> errors sometimes might as well just say 'I just cannot run!'.  It would be
>> nice if there was some facility to approximately point to some s-exp or
>> line numbers.
>>
>> May be I am missing some workflow used by other expert users. Can someone
>> throw more light on this.
>>
>>
>> Thanks
>> Guru
>>
>

-- 
-- 
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
--- 
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 clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to