Refactored error handling and logging of ci tasks