mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-08 07:52:40 +01:00
Improve the quality of SSH error messages
Summary: See PHI1784. Currently, users who pass an invalid SSH command to Phabricator's SSH handler get an unhelpful error message. Make it more helpful. Test Plan: Ran `./bin/ssh-exec` with no arguments (old, helpful error), invalid arguments (before: unhelpful error; after: helpful error), and valid arguments (old, helpful behavior). Differential Revision: https://secure.phabricator.com/D21362
This commit is contained in:
parent
8c7f114b4d
commit
9ce1271805
1 changed files with 36 additions and 15 deletions
|
@ -211,21 +211,29 @@ try {
|
|||
->setUniqueMethod('getName')
|
||||
->execute();
|
||||
|
||||
$command_list = array_keys($workflows);
|
||||
$command_list = implode(', ', $command_list);
|
||||
|
||||
$error_lines = array();
|
||||
$error_lines[] = pht('Welcome to Phabricator.');
|
||||
$error_lines[] = pht(
|
||||
'You are logged in as %s.',
|
||||
$user_name);
|
||||
|
||||
if (!$original_argv) {
|
||||
throw new Exception(
|
||||
pht(
|
||||
"Welcome to Phabricator.\n\n".
|
||||
"You are logged in as %s.\n\n".
|
||||
"You haven't specified a command to run. This means you're requesting ".
|
||||
"an interactive shell, but Phabricator does not provide an ".
|
||||
"interactive shell over SSH.\n\n".
|
||||
"Usually, you should run a command like `%s` or `%s` ".
|
||||
"rather than connecting directly with SSH.\n\n".
|
||||
"Supported commands are: %s.",
|
||||
$user_name,
|
||||
'git clone',
|
||||
'hg push',
|
||||
implode(', ', array_keys($workflows))));
|
||||
$error_lines[] = pht(
|
||||
'You have not specified a command to run. This means you are requesting '.
|
||||
'an interactive shell, but Phabricator does not provide interactive '.
|
||||
'shells over SSH.');
|
||||
$error_lines[] = pht(
|
||||
'(Usually, you should run a command like "git clone" or "hg push" '.
|
||||
'instead of connecting directly with SSH.)');
|
||||
$error_lines[] = pht(
|
||||
'Supported commands are: %s.',
|
||||
$command_list);
|
||||
|
||||
$error_lines = implode("\n\n", $error_lines);
|
||||
throw new PhutilArgumentUsageException($error_lines);
|
||||
}
|
||||
|
||||
$log_argv = implode(' ', $original_argv);
|
||||
|
@ -247,7 +255,20 @@ try {
|
|||
$parsed_args = new PhutilArgumentParser($parseable_argv);
|
||||
|
||||
if (empty($workflows[$command])) {
|
||||
throw new Exception(pht('Invalid command.'));
|
||||
$error_lines[] = pht(
|
||||
'You have specified the command "%s", but that command is not '.
|
||||
'supported by Phabricator. As received by Phabricator, your entire '.
|
||||
'argument list was:',
|
||||
$command);
|
||||
|
||||
$error_lines[] = csprintf(' $ ssh ... -- %Ls', $parseable_argv);
|
||||
|
||||
$error_lines[] = pht(
|
||||
'Supported commands are: %s.',
|
||||
$command_list);
|
||||
|
||||
$error_lines = implode("\n\n", $error_lines);
|
||||
throw new PhutilArgumentUsageException($error_lines);
|
||||
}
|
||||
|
||||
$workflow = $parsed_args->parseWorkflows($workflows);
|
||||
|
|
Loading…
Reference in a new issue