mostrar el mensaje de error apropiado al usuario de la llamada Meteor

I am working with Meteorjs First time. In my application I am trying to Register a use. For this I am making a meteor call. Which returns me error if it is unsuccessful or success if user is registered successfully. My problem is when Someone try to register a user with a previously registered id meteor call returns error message that user name is already exists.this is my meteor call

var acct = {"email": email, "full_name": full_name, roles: roles}
var id = Meteor.call("register_staff", acct, function (error, result) {
if (error) {
     console.log(error)
     FlashMessages.sendError(" This email address is already registered")
} 
else {
       $("#user_creator_dialog").modal('hide');
       FlashMessages.sendSuccess("User Successesfully Created and Password Mailed")
     }
  }); 

si lo hago

 console.log(error)  

it shows me a Key value pair

Error: Username is already exists.
But when I try to get the key by using dot(.) notation like
console.log(error.Error)

it gives undefined

. my question is how can i access this error object key. before this i worked with javascript and jquery where dot notation works perfectly. I think in meteor there may be some other way to access this key.

preguntado el 27 de noviembre de 13 a las 06:11

1 Respuestas

If your Meteor method is throwing a new Meteor.Error the keys will include error, errorType, message, reason, and details. "Error" is the object but not one of the keys so "error.Error" in your callback will return undefined.

Try error.reason or error.message and see if that does it. It depends what is being returned from the method.

respondido 27 nov., 13:06

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.