Handling of error and using headers from last response