Add method to cancel an activity with an error.