yusanshi / emgithub

Embed a file from GitHub repository just like GitHub Gist.
https://emgithub.com
MIT License
409 stars 77 forks source link

More intuitive message on error status codes #1

Closed weirane closed 4 years ago

weirane commented 4 years ago

It turns out that an error status code of fetching does not result in an error, so catch clauses will not be executed and the error message from raw.githubusercontent.com is displayed. This patch enables checks for responses' status code to make those errors more intuitive.

404: Not Found

=>

Failed to write https://raw.githubusercontent.com/vuejs//dev/src/core/index.js: Response was not ok: 404 Not Found

https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch#Checking_that_the_fetch_was_successful

yusanshi commented 4 years ago

Thx a lot!