added curl errors exception handling to code