0

I'm working on a web project and I need to serve some files but I want to be able to handle errors in my application in the event that serving the file / content fails. I've written functions to check for most of the common issues that I'm intending to deal with but, to be fully compliant as I hope to make this reusable for others. Therefore, it would be great if there was a way to ensure that lower-level errors weren't just automatically sent to an old http.Error and not dealt with.

I don't know of a way to deal with those errors unfortunately. I know this is probably by design as it'd be complicated to describe the issue back to the requestor and deal with it in a compliant way but, it just seems a bit too final to just get a http.Error that can't be dealt with.

Sooo, does anyone know of a way to deal with those cases that I'm not thinking of? Re-writing serveContent seems entirely unwise (and entirely complicated) so I'm not going down that route. If it isn't possible, then it is what it is I suppose.

  • How do you want to handle the errors? Do want to override what http.Error does? Is it sufficient to know the HTTP status code sent for a request, or do you want the error value returned from opening or reading files? – Cerise Limón Apr 16 at 1:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.