adding switch to control whether the task fails on error