If there's an SQL error during node save (ex. trying to save a node with a blank taxonomy term) you get an SQL error. Something like:

WD node: PDOException: SQLSTATE[HY000]: General error: 1366 Incorrect integer value: '' for column 'tid' at row 1: INSERT INTO  [error]
{taxonomy_index} (nid, tid, sticky, created) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1,
:db_insert_placeholder_2, :db_insert_placeholder_3); Array
(
    [:db_insert_placeholder_0] => 244334
    [:db_insert_placeholder_1] => 
    [:db_insert_placeholder_2] => 0
    [:db_insert_placeholder_3] => 1311630851
)

Since the exception means that the node save transaction gets rolled back, node 244334 doesn't exist. Thus there's no way to figure out what source record caused the error. However if we wrap the node_save() in a try-catch we can show a message about what the source record ID was.

Comments

dalin’s picture

StatusFileSize
new736 bytes

This patch shows what I had in mind. However I'm not sure how to figure out what fields in $row are the source PK(s).

dalin’s picture

Status: Active » Needs review
mikeryan’s picture

Status: Needs review » Postponed (maintainer needs more info)

There is already a try/catch around the call to the destination import() in Migration::import() - it saves the caught message to the migrate_message table with the source ID triggering the problem. Is this somehow failing to work that way for you? I much prefer having the try/catch logic in one place to implementing it individually in each destination plugin.

Thanks.

mikeryan’s picture

Status: Postponed (maintainer needs more info) » Closed (works as designed)

No further information.

kenorb’s picture

Issue summary: View changes

You can implement your own catch, e.g.

 /**
  * Implements Migration::import().
  *
  * @inheritdoc
  */
 public function import() {
   try {
     return parent::import();
   }
   catch (PDOException $e) {
      $this->showMessage(var_export($e, TRUE));
      // watchdog_exception('foo_migrate', $e);
   }
 }