Fix bug causing document server to not return errors correctly