2 thoughts on “onClose – Possible Unhandled Promise Rejection

  1. @andyfenelon, @IsTheJack, Actually, this is solved by just adding in a catch. If a user doesn’t share, it throws an error of Object {error: "User did not share"} — which will be unhandled without a catch.

    So to prevent the warning you can do:

    Share.open({
      // share config here
    })
    .catch(err => console.log(err));
    
  2. I don’t really like this workaround. IMO the module shouldn’t reject the promise in this case because it’s not an “error scenario”. Can anybody reopen the issue ?

    At least, the rejected value must allow distinction between this case and real errors (creating a UserCancelError should do the job).

    According to the JS coding conventions, a promise should reject a instance of Error (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/reject#Description), not an object containing a key named error

    I’d remove the use of Exception that is not standard in JavaScript: https://github.com/EstebanFuentealba/react-native-share/blob/master/index.js#L71 (or maybe it’s a Windows thing ?)

    Are you guys open to a PR ?

2 thoughts on “onClose – Possible Unhandled Promise Rejection

  1. @andyfenelon, @IsTheJack, Actually, this is solved by just adding in a catch. If a user doesn’t share, it throws an error of Object {error: "User did not share"} — which will be unhandled without a catch.

    So to prevent the warning you can do:

    Share.open({
      // share config here
    })
    .catch(err => console.log(err));
    
  2. I don’t really like this workaround. IMO the module shouldn’t reject the promise in this case because it’s not an “error scenario”. Can anybody reopen the issue ?

    At least, the rejected value must allow distinction between this case and real errors (creating a UserCancelError should do the job).

    According to the JS coding conventions, a promise should reject a instance of Error (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/reject#Description), not an object containing a key named error

    I’d remove the use of Exception that is not standard in JavaScript: https://github.com/EstebanFuentealba/react-native-share/blob/master/index.js#L71 (or maybe it’s a Windows thing ?)

    Are you guys open to a PR ?