Fix error handling so that the fetch utility to properly detect invalid urls. Ticket #4018