mre/vscode-snippet

Catch error when making axios request

mre opened this issue ยท 10 comments

mre commented

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.

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

mre commented

Sure. Assigning to you. Thanks! ๐Ÿ˜Š

Did this ever get solved..? If not, I can and will.

mre commented

Go for it. โค๏ธ

Didn't forget about this. Just been busy with two jobs and redoing my portfolio. I'll keep you updated.

@mre ok to update dependencies, replace tslint (deprecated) with eslint, configure prettier while i'm at it, etc.? also, I think you need to add me as a contributor, still?

mre commented

Hey, that's all fine. Feel free to create a pull request for those changes. No need to be added as a contributor for that. This can happen later after a few pull requests. ๐Ÿ™‚

Ok, great! Yeah actually, that makes sense. I did not realize I could put in a PR, if not added as a contributor. I should have a PR in by Monday, 6/24. ๐Ÿ‘

mre commented

This is fixed now thanks to @jarusll. ๐Ÿฅณ

@mre ugh my fault for flakin' on this... Had something workable too, but the job & other responsibilities these past few months have been very demanding of me. I'd like to see if I can solve another issue on this project sometime, now that my I've got more free time. Thanks @jarusll for picking this up.