You are here

function patterns_error_check_results in Patterns 7.2

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

Helper function for checking errors.

2 calls to patterns_error_check_results()
patterns_implement_action in includes/core/common.inc
Setup and run an 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, $prefix = '') {
  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;
  }
  $msg = $prefix . t(' 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'];
  $result['msg'] = $msg;
  watchdog('patterns', $msg, array(), $wd_type);

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