eligrey / FileSaver.js

An HTML5 saveAs() FileSaver implementation
https://eligrey.com/blog/saving-generated-files-on-the-client-side/
Other
21.58k stars 4.38k forks source link

How to handle a error? #759

Open alexaung opened 2 years ago

alexaung commented 2 years ago

I got "could not download file" error sometime because of server issue.

But I could not find the way to show this error message to user. Is there a way tho show the such kind of error message to user?

abnersouza commented 1 year ago

@alexaung you can use a try catch

try {
      saveAs(this.urlPdf, `${this.title}.pdf`);
    } catch (error) {
      console.error("Failed to download PDF");
    }