You are here

function patterns_error_check_results in Patterns 7

Same name and namespace in other branches
  1. 7.2 includes/error.inc \patterns_error_check_results()

Helper function for checking errors.

5 calls to patterns_error_check_results()
patterns_batch_action in includes/core/batch.inc
Executes a batch action.
patterns_execute_pattern_php in includes/core/php.inc
Execute a Pattern. Actions will be called sequentially.
patterns_implement_action in includes/core/common.inc
Setup and run an action.
patterns_php_action in includes/core/php.inc
Execute a single pattern action.
patterns_prepare_action in includes/core/common.inc
Preparing and validating the action tags as they are written in the pattern file. Concretely, it invokes operations 'prepare', and 'validate' on the pattern component.

File

includes/error.inc, line 143
Error handling.

Code

function patterns_error_check_results(&$result) {
  if ($result['status'] == PATTERNS_ERR) {
    $return = FALSE;
    $wd_type = WATCHDOG_ERROR;
    $msg_type = 'error';
  }
  elseif ($result['status'] == PATTERNS_WARN) {
    $return = TRUE;
    $wd_type = WATCHDOG_WARNING;
    $msg_type = 'warning';
  }
  else {

    // Success.
    return TRUE;
  }

  // TODO: t()?
  $msg = 'Error occurred in ';
  if (isset($result['details'])) {
    $msg = 'Hook: ' . $result['details']['hook'];
    $msg .= ', Action: ' . $result['details']['action'];
    $msg .= ', Function: ' . $result['details']['function'] . '. ';
  }
  else {
    $msg .= 'unspecified action. ';
  }
  $msg = empty($result['msg']) ? $msg : $msg . $result['msg'];
  watchdog('patterns', $msg, array(), $wd_type);

  // TODO: $msg is not a literal string.
  drupal_set_message($result['msg'], $msg_type);
  return $return;
}