Error handling 有没有更好的方法来捕获clojurescript中的javascript错误?
我一直在clojurescript中与firebase合作,我在这里尝试了以下建议: 到目前为止,我掌握的代码是:Error handling 有没有更好的方法来捕获clojurescript中的javascript错误?,error-handling,interop,firebase-authentication,clojurescript,Error Handling,Interop,Firebase Authentication,Clojurescript,我一直在clojurescript中与firebase合作,我在这里尝试了以下建议: 到目前为止,我掌握的代码是: (defn register [email password] (try (let [reg (.createUserWithEmailAndPassword (.auth firebase) email password) _ (.log js/console reg)] reg) (catch :default e
(defn register [email password]
(try
(let [reg (.createUserWithEmailAndPassword (.auth firebase) email password)
_ (.log js/console reg)]
reg)
(catch :default e
(.log js/console "Register Error:" e))))
正如我所怀疑的,它没有被发现的原因是评估可能会在以后发生,这是为了测试这个想法
我也尝试过:
(defn register [email password]
(try
(.createUserWithEmailAndPassword (.auth firebase) email password)
(catch :default e
(.log js/console "Register Error:" e))))
我称之为:
(apply register ((juxt :email :password) @app-state))
如果我给它发了一封我已经注册过的电子邮件,我会像预期的那样收到一封已在使用的auth/email
错误,但我抓不到它
www.googleapis.com/identitytoolkit/v3/relyingparty/signupNewUser?key=AIzaSyDzsfz98Y6Pjl1n-uAzfI6GHWKqShFdRI4:1
POST https://www.googleapis.com/identitytoolkit/v3/relyingparty/signupNewUser?key=AIzaSyDzsfz98Y6Pjl1n-uAzfI6GHWKqShFdRI4 400 ()
firebase.inc.js:81
Uncaught
Qcode: "auth/email-already-in-use"
message: "The email address is already in use by another account."
__proto__: Error
(anonymous) @ firebase.inc.js:81
我怎么抓住它?还是使用原始javascript是处理此问题的唯一方法
firebase.auth().createUserWithEmailAndPassword(email, password).catch(function(error) {
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
// ...
});
Firebase身份验证是异步的。Javascript的(通常还有Clojurescript的)
try…catch
在回调中不起作用。调用Firebase处理程序提供的catch
函数,并在出现错误时进行回调,如下所示-这是上面文章中JS代码的直译:
(defn register [email password]
(.. firebase auth (createUserWithEmailAndPassword email password)
(catch (fn [e] (.log js/console "Register Error:" e))))
Firebase身份验证是异步的。Javascript的(通常还有Clojurescript的)
try…catch
在回调中不起作用。调用Firebase处理程序提供的catch
函数,并在出现错误时进行回调,如下所示-这是上面文章中JS代码的直译:
(defn register [email password]
(.. firebase auth (createUserWithEmailAndPassword email password)
(catch (fn [e] (.log js/console "Register Error:" e))))