/**
  * Creates a valid JobStepResponse object from an exception and method name.
  * @param \Exception $exception
  * @param string $method_name
  * @return JobStepResponse
  */
 protected function _get_error_response(\Exception $exception, $method_name)
 {
     if (!$this->_job_parameters instanceof JobParameters) {
         $this->_job_parameters = new JobParameters($this->_job_id, __('__Unknown__', 'event_espresso'), array());
     }
     $this->_job_parameters->set_status(JobParameters::status_error);
     return new JobStepResponse($this->_job_parameters, sprintf(__('An exception of type %1$s occurred while running %2$s. Its message was %3$s and had trace %4$s', 'event_espresso'), get_class($exception), 'BatchRunner::' . $method_name . '()', $exception->getMessage(), $exception->getTraceAsString()));
 }
 public function continue_job(JobParameters $job_parameters, $batch_size = 50)
 {
     $csv_data = $this->get_csv_data($job_parameters->units_processed(), $batch_size);
     \EEH_Export::write_data_array_to_csv($job_parameters->extra_datum('filepath'), $csv_data, false);
     $units_processed = count($csv_data);
     $job_parameters->mark_processed($units_processed);
     $extra_response_data = array('file_url' => '');
     if ($units_processed < $batch_size) {
         $job_parameters->set_status(JobParameters::status_complete);
         $extra_response_data['file_url'] = $this->get_url_to_file($job_parameters->extra_datum('filepath'));
     }
     return new JobStepResponse($job_parameters, sprintf(__('Wrote %1$s rows to report CSV file...', 'event_espresso'), count($csv_data)), $extra_response_data);
 }