further improve error handling for curl calls