Fix error handling to catch NotFound exceptions