H
H
humanIvan2018-08-07 11:12:21
JavaScript
humanIvan, 2018-08-07 11:12:21

How to forward the error down?

Please tell me how to forward your error down.
5b6954523e75f443353342.png

export const logIn = (email, password, displayName) => {
  return async (dispatch) => {
    try {
      let db = firebase.firestore();
      const settings = { timestampsInSnapshots: true };
      db.settings(settings);
      let NameRef = db.collection("Users").doc(displayName);
      let Name = await NameRef.get();
      if(Name.exists){
        throw new Error("Имя"); 
      }else{
        await firebase.auth().createUserWithEmailAndPassword(email, password);
        let User = await firebase.auth().currentUser;
        await User.updateProfile({ displayName: displayName });
        let Uid = { uid: User.uid };
        dispatch(writesUser(User));
        await axios.post('/api/emailVerified', Uid);
      }
    } catch (e) {
      throw e;
    }
  };
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Spirin, 2018-08-07
@humanIvan

Type entry:

try {
  throw new Error('Ooops!');
} catch (e) {
  throw e;
}

Equivalent: An error in the catch block should not be initiated, but handled:
try {
  throw new Error('Ooops!');
} catch (e) {
  alert(e);  // например, выводим ошибку в alert
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question