dom111/webdav-js

4xx errors not caught

chrysn opened this issue · 2 comments

When a filedirectory comes back 403, the "changing the folder" spinner stays on and the console reports

XML Parsing Error: mismatched tag. Expected: </hr>.
Location: http://my-host/a-forbidden-directory
Line Number 6, Column 3:

To me it looks like there go wrong two things:

  • The returned media type is not text/xml but text/html, but parsing it as directory listing XML is still attempted.
  • The returned representation came back on a 4xx code, indicating the response is an error and not a representation of the requested resource, and parsing is still attempted.

I think the desirable behavior would be to show some (probably modal) error message, possibly even an iframe(-ish? are they still a thing?) representation of the HTML response.

edit: I tested this originally on directories but mistyped it as files. Correcting that I tested it on files as well, and they could probably use the same fixes, given that a 403 HTML file displays the error message (syntax highlit -- cool!) and tries to play the media.

Yeah, this is a good shout. I think I'd like to add some sort of toast/notification to all errors and with the restructuring it should be easy to just add a .catch to the fetch for all failures identifying what failed and why. I'll do this for 2.0 0 too.

Thanks for resting!

This should be fixed in v2.0.0