Searching through Drush make, just about every call to drush_set_error passes the message in as the $error parameter.

$ find commands/make/ -exec grep -Hi 'drush_set_error' {} \;
commands/make/make.drush.inc:      drush_set_error(dt('No core project specified.'));
commands/make/make.drush.inc:    drush_set_error(dt('No core project specified.'));
commands/make/make.drush.inc:    return drush_set_error(dt('More than one core project specified.'));
commands/make/make.drush.inc:    return drush_set_error(dt('Base path %path already exists', array('%path' => $build_path)));
commands/make/make.drush.inc:    drush_set_error(dt("Cannot move build into place"));
commands/make/make.project.inc:      drush_set_error(dt('Directory not empty: !directory', array('!directory' => $this->download_location)));
commands/make/make.project.inc:      drush_set_error(dt('Directory not empty: !directory', array('!directory' => $this->download_location)));
commands/make/make.utilities.inc:    return drush_set_error(dt('Invalid or empty make file: !makefile', array('!makefile' => $makefile)));
commands/make/make.utilities.inc:    drush_set_error($error_code, $message);
commands/make/make.download.inc:        return drush_set_error('DRUSH_MAKE_SUBTREE_NOT_FOUND', dt('Directory !subtree not found within !file', array('!subtree' => $subtree, '!file' => $filename)));

The output is displayed correctly to the user, because the drush_set_error function includes the following logic:

    drush_log(($message) ? $output_label . $message : $output_label . $error, 'error', $error);

In other words, if there is no $message, then $error is printed. This looks okay to the user, but is semantically different in code; even though $error and $message are both strings, $error is supposed to take the form of DRUSH_MAKE_SUBTREE_NOT_FOUND, whereas $message is supposed to be a human-readable string -- the later being localizable, the former not.

While it makes little operational difference, it would be more correct to define and use $error codes throughout Drush make. Without them, it is more difficult for scripts that call Drush to react correctly to different error codes.

CommentFileSizeAuthor
#2 drush-make-set-error-1880678-01.patch3.72 KBjhedstrom
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jhedstrom’s picture

Version: » 8.x-6.x-dev
Status: Active » Needs review

Good catch.

jhedstrom’s picture

greg.1.anderson’s picture

Status: Needs review » Reviewed & tested by the community

Awesome. Thanks.

jhedstrom’s picture

Status: Reviewed & tested by the community » Fixed

Committed to 5 and 6.

greg.1.anderson’s picture

Not sure this should have gone into 5, since it is possible that someone might be doing string compares on these result codes anyway. Unlikely, I guess, so I'm indifferent to whether or not it gets backed out.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.