added error handling to rake task