Skip to content

Error catch causes error that hides the real error. #229

@robblovell

Description

@robblovell

Also, there is a problem in the client code:

Here:

 async request(method, path, options = {}) {
    try {
   ...
    } catch (error) {
      let clientError;
      try {
        const response = JSON.parse(error.response.body);
        clientError = new NgrokClientError(
          response.msg,
          error.response,
          response
        );
      } catch (e) {
        clientError = new NgrokClientError(
          error.response.body,
          error.response,
          error.response.body
        );
      }
      throw clientError;
    }
  }

Some errors don't have a response or a response.body and you "typeerror cannot read property 'body' of undefined", probably from the second catch... It would be better to just return the error. When doing so, you get a much more useful message that helped to debug the above missing await (ngrok is not yet ready to start tunnels):

in client.js

 async request(method, path, options = {}) {
    try {
   ...
    } catch (error) {
      let clientError;
      try {
        const response = JSON.parse(error.response);
        clientError = new NgrokClientError(
          response.msg,
          error.response,
          response
        );
      } 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions