Automatically restart task when error occurs