Improve error message handling

Improve handling of Authentication errors and Not Found errors.