Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

While making a invalid query error is not handle in catch block #16

Open
sulaimaan26 opened this issue Dec 29, 2020 · 3 comments
Open

Comments

@sulaimaan26
Copy link

sulaimaan26 commented Dec 29, 2020

This is not handled properly.

For example, we need to check some data is exist in the collection or not. if it does not exist it should throw an error and can be properly handled try-catch but the error is displayed only in the console doesn't go to catch block

Only console. error is done not an exception is thrown

Steps to Reproduce

  1. Launch URL https://sulaimaan26.github.io/
  2. Open browser dev tools and proceed to console
  3. Look for any error
  4. Refresh the page
  5. Now only one error will be displayed in the console
  6. This is console.error which is displayed for an invalid query made
  7. Now proceed to the source tab and view app.js file

In app.js file you could see there is two query doc search based on id one is valid and another one is invalid inside a try-catch block. For an invalid search, the only console.error is thrown not an error exception which is not handled by the catch block.

However, the function returns undefined as return value where the user can validate with it but it will be good if error exception is thrown same like RDBMS database

@dannyconnell
Copy link
Collaborator

@sulaimaan26 Can you provide example code for recreation?

@sulaimaan26
Copy link
Author

@sulaimaan26 Can you provide an example code for recreation?

@dannyconnell I have updated the issue description. Refer to it

@larskuerten
Copy link

If you try check for an unexistent collection, it create a new collection and doesnt throw error

    async function getUsers() {
      try {
        let users = await db
          .collection('users') // nonexistent collection
          .orderBy('age')
          .get();
        console.log('users: ', users); // it shows an empty collection called users
      } catch (error) {
        console.log('error: ', error); // the catch isnt reached
      }
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants