The Wayback Machine - https://web.archive.org/web/20210105132031/https://github.com/mre/vscode-snippet/issues/83
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

Catch error when making axios request #83

Open
mre opened this issue Oct 1, 2020 · 2 comments
Open

Catch error when making axios request #83

mre opened this issue Oct 1, 2020 · 2 comments

Comments

@mre
Copy link
Owner

@mre mre commented Oct 1, 2020

The request handling of this VSCode plugin is not handling errors at the moment.
Here is the request code:

private async _doRequest(): Promise<AxiosResponse> {
let query = encodeURI(this.currQuery.replace(/ /g, "+"));
let url = this.getUrl(this.currLanguage, query);
let data = this.requestCache[url];
if (data) {
return data;
}
let res = await axios.get(url, this._requestConfig());
this.requestCache[url] = res;
return res;
}
}

As you can see, we don't check for errors in line 106.
It would be great to catch errors there and show and error message to the user.
You can test this by going offline and searching for a snippet. In this case it should show an error message (and not silently fail).

Fixing this issue will probably help troubleshooting #77, so there is some real user value.

@brew-install-buzzwords
Copy link

@brew-install-buzzwords brew-install-buzzwords commented Oct 1, 2020

Hi, I can take this issue if it's still available

@mre
Copy link
Owner Author

@mre mre commented Oct 1, 2020

Sure. Assigning to you. Thanks! 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.