error handling exmaples and updated code examples