Error Handling

Last modified: April 3, 2009 - 18:04

Issue for adding error documentation: #422092: Error reporting with $errors array needs documentation.

When implementing a hook, the return value is and array of errors in the following format. Errors are then stored in the database in the mytable_mydestination_msg table which is available through views.

Example error message format:

<?php
  $errors
[] = array(
   
'sourceid' => $field, //string
   
'level' =>  $err_level, //constant
   
'message' =>  'My error message',
  );
?>

Message Components

sourceid

unknown

level

a constant. See "error level constants" below.

message

A test string containing the message you want to store

Error Level Constants

Counts of errors appear on the Process page under "Unimported" or "Imported" columns depending on the level.

MIGRATE_MESSAGE_ERROR =1

Halts Processing.

MIGRATE_MESSAGE_WARNING = 2

Halts Processing.

MIGRATE_MESSAGE_NOTICE =3

Halts Processing.
The idea of the NOTICE level is for cases where unwanted content could not be filtered out in the content set, it could only be identified in the prepare hook. So, if you complete a migration and #notices = total unimported (no errors or warnings), you're good to go...

MIGRATE_MESSAGE_INFORMATIONAL =4

Doesn't halt processing. Content is imported.
allows the import to complete - counts of these appear in the Imported column. This would be used in cases where you can construct a valid destination object, but there's some condition that may need attention after the fact.

Accessing Messages

SQL *_msg tables are available to code as is. Automatic Views integration is in the works. #392416: Integrate migration messages with views

 
 

Drupal is a registered trademark of Dries Buytaert.