Anvil Community Forum

Improve the error message when trying to download a media that does not exist

A form calls a server function with a file name, the server function returns the media url with return app_tables.pdffiles.get(key=file_name)['pdf'].get_url(False), the form shows the PDF file with anvil.js.window.location = pdf_url.

If the row is deleted before the browser starts downloading the file, the browser shows Internal server error: bec52f76ffb9:


I would like for the error message to be something helpful, like Error: the file specified in the URL does not exist.

It is very unlikely for the browser to try to download a file stored in a row that has been deleted, but in my case I had two background tasks running in parallel and messing with each other rows, and investigating the nature of the problem with such a cryptic error message wasn’t fun.

1 Like