function Provision_ChainedState::fail

7.x-3.x ChainedState.php Provision_ChainedState::fail($message, $error_codes = NULL)

Log a notice into the logging system, if the last operation did not complete succesfully.


$message: Log this as a error to the logging system, if the $error_codes parameter has been set, otherwise, log this as a warning. If the operation specifies an additional reason for the operation failing, it will be appended to this message.

error_codes: Generate these system level errors using the provision error bitmasks.


Provision/ChainedState.php, line 62
The Provision_ChainedState class.


A base class for the service and file handling classes that implements chaining of methods.


function fail($message, $error_codes = NULL) {
  if (!empty($this->tokens['@reason'])) {
    $message .= ' (@reason)';
  if ($this->last_status === FALSE) {
    if (is_null($error_codes)) {
      // Trigger a warning
      drush_log(dt($message, $this->tokens), 'warning');
    else {
      // Trigger a sysem halting error
      drush_set_error($error_codes, dt($message, $this->tokens));

  return $this;