function drush_set_error

8.0.x drush_set_error($error, $message = null, $output_label = "")
6.x drush_set_error($error, $message = null, $output_label = "")
7.x drush_set_error($error, $message = null, $output_label = "")
3.x drush_set_error($error, $message = null)
4.x drush_set_error($error, $message = null)
5.x drush_set_error($error, $message = null, $output_label = "")
master drush_set_error($error, $message = null, $output_label = "")

Set an error code for the error handling system.


error: A text string identifying the type of error.

message: Optional. Error message to be logged. If no message is specified, hook_drush_help will be consulted, using a key of 'error:MY_ERROR_STRING'.

Return value

Always returns FALSE, to allow you to return with false in the calling functions, such as <code>return drush_set_error('DRUSH_FRAMEWORK_ERROR')</code>

Related topics

126 calls to drush_set_error()
core_watchdog_query in commands/core/
Build a WHERE snippet based on given parameters.
DrushBatchContext::offsetSet in includes/
DrushMakeProject::findDownloadLocation in commands/make/
Determine the location to download project to.
DrushMakeProject_Core::findDownloadLocation in commands/make/
Determine the location to download project to.
drush_archive_dump in commands/core/
Command callback. Generate site archive file.

... See full list


includes/, line 1816
The drush API implementation and helpers.


function drush_set_error($error, $message = null, $output_label = "") {
  $error_code = &drush_get_context('DRUSH_ERROR_CODE', DRUSH_SUCCESS);
  $error_code = DRUSH_FRAMEWORK_ERROR;

  $error_log = &drush_get_context('DRUSH_ERROR_LOG', array());

  if (is_numeric($error)) {

  $message = ($message) ? $message : drush_command_invoke_all('drush_help', 'error:' . $error);

  if (is_array($message)) {
    $message = implode("\n", $message);

  $error_log[$error][] = $message;
  if (!drush_backend_packet('set_error', array('error' => $error, 'message' => $message))) {
    drush_log(($message) ? $output_label . $message : $output_label . $error, 'error', $error);

  return FALSE;