Skip to content

Commit

Permalink
Fix fatal on datasource error
Browse files Browse the repository at this point in the history
  • Loading branch information
eileenmcnaughton committed Feb 21, 2023
1 parent 63c54bb commit b22688e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion CRM/Import/DataSource/SQL.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,12 @@ public static function formRule($fields, $files, $form) {
public function initialize(): void {
$table = CRM_Utils_SQL_TempTable::build()->setDurable();
$tableName = $table->getName();
$table->createWithQuery($this->getSubmittedValue('sqlQuery'));
try {
$table->createWithQuery($this->getSubmittedValue('sqlQuery'));
}
catch (PEAR_Exception $e) {
throw new CRM_Core_Exception($e->getMessage(), 0, ['exception' => $e]);
}

// Get the names of the fields to be imported.
$columnsResult = CRM_Core_DAO::executeQuery(
Expand Down
7 changes: 6 additions & 1 deletion CRM/Import/Form/DataSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,12 @@ protected function processDatasource(): void {
$this->flushDataSource();
$this->updateUserJobMetadata('submitted_values', $this->getSubmittedValues());
}
$this->instantiateDataSource();
try {
$this->instantiateDataSource();
}
catch (CRM_Core_Exception $e) {
CRM_Core_Error::statusBounce($e->getMessage());
}
}

/**
Expand Down

0 comments on commit b22688e

Please sign in to comment.