Add error handling to rake task