You are here

function Messaging_Message::set_error in Messaging 7

Same name and namespace in other branches
  1. 6.4 includes/messaging_message.class.inc \Messaging_Message::set_error()
  2. 6.3 classes/messaging_message.class.inc \Messaging_Message::set_error()

Set error condition and stop processing

Parameters

$text: Error message to be stored

File

./messaging.message.inc, line 590
Drupal Messaging Framework - Message class file

Class

Messaging_Message
Message class

Code

function set_error($code = 1, $text = NULL) {

  // This will stop processing if we are in the middle of anything
  $this
    ->set_status(self::STATUS_ERROR);
  $text = $text ? $text : t('Error code !code', array(
    '!code' => $code,
  ));
  $this
    ->set_text('error', $text);
  $this->result = FALSE;
  $this->error = $code;
  $this
    ->message_log('Error processing message.');

  // By default, messages are set to be logged when errors happen
  if ($this->log_error) {
    $this->log = 1;
  }
  elseif (!$this->log) {

    // Not for logging, discard
    $this->discard = TRUE;
  }
}