implementation of error handling in the requests functions