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

Do not throw undefined when the response body does not match the intercom API format #382

Open
BogdanCln opened this issue Oct 3, 2023 · 0 comments

Comments

@BogdanCln
Copy link

BogdanCln commented Oct 3, 2023

Version info

  • intercom-node version: 4.0.0
  • Node version: 18

Expected behavior

We are using an HTTP proxy for all the outbound requests.
If the proxy cannot establish the HTTP tunnel to api.intercom.com, we expect an exception that is easy to debug.

Actual behavior

undefined is thrown when an error that is not parsable is encountered; in our case: when the proxy server cannot reach intercom API.
The Client.checkOnErrorInResponse() returns undefined when the error does not have the intercom API format.
In this case, I think that setting the response body as an error message (instead of undefined) would be a nice improvement.

Steps to reproduce

  1. set baseURL to a local HTTP server that responds with a >=400 status code:
client.useRequestOpts({
    baseURL: 'http://local.test-server.com',
});
  1. Launch a request via intercom client, e will be undefined
try {
    await intercom.ping();
} catch (e) {
    console.error(e);
}
@BogdanCln BogdanCln changed the title Do not throw 'null' when the response body does not match the intercom API format Do not throw undefined when the response body does not match the intercom API format Oct 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant