custom-protocol-detection icon indicating copy to clipboard operation
custom-protocol-detection copied to clipboard

firefox NS_ERROR_FAILURE

Open mafar opened this issue 7 years ago • 3 comments

Consider change below. This is because if protocol is registered but app is not there then firefox throws another error e.name==NS_ERROR_FAILURE

if (e.name == "NS_ERROR_UNKNOWN_PROTOCOL") {
            failCb();
}

to

if (e ) {
            failCb();
}

mafar avatar Apr 11 '17 23:04 mafar

It would be better to only trigger the failure callback for exceptions related to protocols. The successCb function may also throw an exception, so you wouldn't want to call failCb in that case.

} catch (e) {
  // Catch errors for either unknown protocols or registered protocols where the associated application isn't installed
  if (e.name == "NS_ERROR_UNKNOWN_PROTOCOL" || e.name == "NS_ERROR_FAILURE") {
    failCb();
  }
}

edwardstumpf avatar Apr 19 '17 13:04 edwardstumpf

@edwardstumpf Yes may be but NS_ERROR_FAILURE indicates protocol might be reigstered but app could not be launched for some reason ( may be exe was moved or does not exist at that path)

See another implementation here. https://gist.github.com/aaronk6/d801d750f14ac31845e8

They put it in unknown callback for this reason

mafar avatar Apr 19 '17 14:04 mafar

I agree that the failure callback should be triggered if the exception throw is NS_ERROR_FAILURE. As you said, this indicates that the application associated with the protocol isn't at the expected location. This could mean that there's an issue with the custom protocol (the wrong path for the application was used) or the application doesn't exist at that location (uninstalled, etc.)

I don't agree that all exception name checking should be removed. The success callback could also throw an exception; this exception would have nothing to do with protocol checking, so the library shouldn't catch that exception.

edwardstumpf avatar Apr 19 '17 15:04 edwardstumpf