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

How to catch returned conflict error in react-native? #395

Closed
ramsestom opened this issue Aug 20, 2016 · 3 comments
Closed

How to catch returned conflict error in react-native? #395

ramsestom opened this issue Aug 20, 2016 · 3 comments

Comments

@ramsestom
Copy link

My feathers server is returning a conflict error (when I try to create a new user with a primary key that already exists in the database)
Here is the error I have on the server:

error: (409) Route: /users - E11000 duplicate key error collection: printsServer.users index: email_1 dup key: { : "toto@yahoo.fr" }
info: Conflict: E11000 duplicate key error collection: printsServer.users index: email_1 dup key: { : "toto@yahoo.fr" }
    at Conflict.ExtendableBuiltin (C:\Development\feathers\prints-server\node_modules\feathers-errors\lib\index.js:21:28)
    at Conflict.FeathersError (C:\Development\feathers\prints-server\node_modules\feathers-errors\lib\index.js:99:87)
    at new Conflict (C:\Development\feathers\prints-server\node_modules\feathers-errors\lib\index.js:236:77)
    at errorHandler (C:\Development\feathers\prints-server\node_modules\feathers-mongoose\lib\error-handler.js:34:27)
    at run (C:\Development\feathers\prints-server\node_modules\core-js\modules\es6.promise.js:87:22)
    at C:\Development\feathers\prints-server\node_modules\core-js\modules\es6.promise.js:100:28
    at flush (C:\Development\feathers\prints-server\node_modules\core-js\modules\_microtask.js:18:9)
    at _combinedTickCallback (internal/process/next_tick.js:67:7)
    at process._tickCallback (internal/process/next_tick.js:98:9)

However, when I catch the error in my react-native app with the following code:

   this.app.service('users').create(userData).then((result) => {
         ... do my stuff here
    }).catch((err) => {
      console.log('err');
      console.log(err);
    });

here is the error message I catch (in the console):

I/ReactNativeJS( 7804): err
I/ReactNativeJS( 7804): { [ReferenceError: Can't find variable: Reflect]
I/ReactNativeJS( 7804):   line: 93539,
I/ReactNativeJS( 7804):   column: 21,
I/ReactNativeJS( 7804):   sourceURL: 'http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false' }

Does anyone knows how I can obtain in my react-native app an error message that is usable (that inform me on the actual error, like on the server, and that I can parse and convert to an error message understandable to the user (like: "an account with this email already exists"))

@daffl
Copy link
Member

daffl commented Aug 20, 2016

Did you include babel-polyfill or another ES6 polyfill (like core-js) as mentioned in the React Native client guide?

@ramsestom
Copy link
Author

No I didn't. I took example from https://github.com/feathersjs/feathers-react-native-chat that doesn't either and didn't see the "important" notice in the tutorial. My bad.
Importing babel-polyfill fixed it. Thanks

@lock
Copy link

lock bot commented Feb 7, 2019

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue with a link to this issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Feb 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants