diff --git a/CRM/Import/DataSource/SQL.php b/CRM/Import/DataSource/SQL.php index ad6ac14ea095..d9fa015d90b2 100644 --- a/CRM/Import/DataSource/SQL.php +++ b/CRM/Import/DataSource/SQL.php @@ -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( diff --git a/CRM/Import/Form/DataSource.php b/CRM/Import/Form/DataSource.php index 6fef3da018d1..95b1bf21ad2b 100644 --- a/CRM/Import/Form/DataSource.php +++ b/CRM/Import/Form/DataSource.php @@ -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()); + } } /**