Skip to content

Potential for improved error messaging for open() failures inside of capture.js #3

@tonype

Description

@tonype

Hello, I was recently troubleshooting why an S800 scanner wasn't able to mount for use with our iOS application. The root cause appears to be that the app info being used is invalid, but in order to get that message I needed to edit capture.js inside of node_modules to see the error being thrown:

https://github.com/SocketMobile/socketmobile-capturejs/blob/main/lib/capture.js#L37

Just for the purposes of seeing if there was any additional error info in the response, I changed it to be:

.then(response => {
      console.log(`SOCKET MOBILE RESPONSE: ${JSON.stringify(response)}`);
      if (response.result && response.result.handle) {
          this.clientOrDeviceHandle = response.result.handle;
          return SktErrors.ESKT_NOERROR;
      }
      throw ({ error: new JRpcError(0, SktErrors.ESKT_COMMUNICATIONERROR, "There was an error during communication.") });

This worked. The shape of the response I received was:

{"jsonrpc":"2.0","error":{"code":-93,"message":"failed to open Capture"},"id":0}

Which gave me the error code, which then led me to ultimately find the ESKT_INVALIDAPPINFO error.

It looks like there may be an opportunity to pass back more specific errors here, rather than swallow the response and default to throwing a generic ESKT_COMMUNICATIONERROR if there is no result property on the response. It's possible I'm not familiar enough with if the shape of the response can be different so I may be off base, but I thought this was at least worth bringing up to consider.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions