Connecting expected errors to call back function