fix 404 and 403 error handling, improve error message output