I want to download a file when I click on a link. The file is served dynamically.
<a href="/server/myfunc?id=XXX" download="proposed_file_name">Download!</a>
But I need to be able to display error to the user if /server/myfunc?id=XXX link does not provide a file. I can return a boolean false or any http code through this link if file isn't present.
What should be the most appropriate method for this implementation. Note that I do not wish to alter the current state of page in any manner, just trigger the file download without affecting the page. And display error if file is not to be downloaded.