Hi, I've got another kinky situation while trying to use some of
swannodette's core.async macro/functions for dealing with async calls in
node.
When dealing with
(defn error? [x]
(instance? js/Error x))
I've noticed that this fn doesn't return true with the exceptions that the
node core API returns (it works fine passing x like (Error. "")).
Here is a small example in the clojurescript node repl:
ClojureScript:cljs.user> (def fs (js/require "fs"))
#<[object Object]>
ClojureScript:cljs.user> (def e (atom nil))
#<Atom: nil>
ClojureScript:cljs.user> (.readFile fs "asdf asdf" (fn [err data]
(reset! e err)))
nil
ClojureScript:cljs.user> e
#<Atom: #<Error: ENOENT, open 'asdf asdf'>>
ClojureScript:cljs.user> (type @e)
#<function Error() { [native code] }>
ClojureScript:cljs.user> (isa? @e js/Error)
false
ClojureScript:cljs.user> (instance? js/Error @e)
false
ClojureScript:cljs.user> (js* "(~{} instanceof ~{})" @e js/Error)
false
And now, the same code in the node repl (which does work):
> fs = require('fs')
{ Stats: [Function],
exists: [Function],
[...]
> fs.readFile("asdfsadfa", function(err, data) { a = err })
undefined
> a
{ [Error: ENOENT, open 'asdfsadfa']
errno: 34,
code: 'ENOENT',
path: 'asdfsadfa' }
> a instanceof Error
true
I'm super confused as by why this happens, and don't know where else to
look. I've been inspecting the cljs source but it looks great and I've also
tried similar code in the browser and node and it works properly:
> (try
(.parse js/JSON "`fasd#$")
(catch js/Error e
(instance? js/Error e)))
true
Any idea of why this might be happening? Any pointers on what to search
for? I'm I doing anything stupid?
Thanks!
ps: the <? macro and run function are supercool
--
Note that posts from new members are moderated - please be patient with your
first post.
---
You received this message because you are subscribed to the Google Groups
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/clojurescript.