Re: One more for the crappy error messages file.

2014-12-07 Thread Mikera
How are you getting that error? Are you sure you aren't just passing a nil 
parameter by accident? For example, I get the same error when I pass nil to 
the clojure.java.io/reader function.

Clojure usually throws file not found exceptions where appropriate, e.g.

(use 'clojure.java.io)

(reader (file ugieceb.doc))
= FileNotFoundException ugieceb.doc (The system cannot find the file 
specified)  java.io.FileInputStream.open (FileInputStream.java:-2)

On Monday, 8 December 2014 13:44:46 UTC+8, Fluid Dynamics wrote:

 IllegalArgumentException No implementation of method: :make-reader of 
 protocol: #'clojure.java.io/IOFactory found for class: nil  
 clojure.core/-cache-protocol-fn (core_deftype.clj:541)

 This, apparently, is clojure.java.io's way of saying file not found. :)

 If there's a list somewhere of specific cases in which to improve the 
 clarity and conciseness of Clojure error reporting, I submit the above as a 
 shoo-in candidate for the new #1 spot and the gold medal in the most in 
 need of improvement Error Message Olympics. :)


-- 
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/d/optout.


Re: One more for the crappy error messages file.

2014-12-07 Thread Fluid Dynamics
On Monday, December 8, 2014 1:29:51 AM UTC-5, Mikera wrote:

 How are you getting that error? Are you sure you aren't just passing a nil 
 parameter by accident? For example, I get the same error when I pass nil to 
 the clojure.java.io/reader function.

 Clojure usually throws file not found exceptions where appropriate, e.g.

 (use 'clojure.java.io)

 (reader (file ugieceb.doc))



I think this instance was something like (with-open [in (io/reader 
(io/resource foo))] ...) with the resource not existing yet. Obviously 
misspelling the resource name would have similar results. It didn't give me 
any trouble as I was actually intentionally missing the resource to check 
error handling. It looks like resource returns nil rather than throwing a 
not found exception, and then reader throws a much more opaque exception. 
Since people will probably often want to chain reader and resource like 
that, and only rarely condition on a resource existing, I'd suggest that 
reader react to nil with a more helpful message identifying the likely 
cause as a resource not found.

-- 
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/d/optout.