获取云代码+ parse.com中的原始错误代码

时间:2014-11-03 16:50:15

标签: parse-platform cloud-code

我是js的新手。我有一个云代码功能来注册用户工作正常,但我无法检索原始错误消息。例如,当我使用现有用户名signUp时,我希望{"code":202,"error":"username cooldude6 already taken"},但得到{"code":141,"error":"An error has occurred"}这是云代码问题的错误代码。任何帮助将不胜感激。

Parse.Cloud.define("signupUserTest", function(request, response) {

Parse.Cloud.useMasterKey(); //to bypass ACLs

var user = new Parse.User();
user.set("email", request.params.email); //optional
user.set("username", request.params.username); //required
user.set("password", request.params.password); //required

user.signUp(null, {
    success: function(user) {    
        response.success("success!");
    },
    error: function(error) {
        console.log(error);
        console.error(error);
        response.error(error.message);
    }
});     
});

日志/错误显示

E2014-11-03T22:39:05.098Z] v593: Ran cloud function signupUser with:
  Input: {"email":"a123@gmail.com","password":"p_n7!-e8","username":"cooldude6"}
  Failed with: An error has occurred

1 个答案:

答案 0 :(得分:0)

赫克托耳在这里指出, https://groups.google.com/forum/#!topic/parse-developers/cydcz_p9rvU

signUp 的错误回调签名缺少用户参数

    error: function(user, error) {
        console.log(error);
        console.error(error);
        response.error(error.message);
    }