1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-08 16:02:39 +01:00

Create a custom exception class for missing linter dependencies

Summary: I feel that we are abusing `ArcanistUsageException`. Throw a more tailed exception instead. Depends on D11197.

Test Plan: `arc lint`, I guess.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: avivey, Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11205
This commit is contained in:
Joshua Spence 2015-01-06 22:45:44 +11:00
parent 0b51f4d7c9
commit 6eed5c2514
7 changed files with 15 additions and 8 deletions

View file

@ -125,6 +125,7 @@ phutil_register_library_map(array(
'ArcanistMercurialParserTestCase' => 'repository/parser/__tests__/ArcanistMercurialParserTestCase.php',
'ArcanistMergeConflictLinter' => 'lint/linter/ArcanistMergeConflictLinter.php',
'ArcanistMergeConflictLinterTestCase' => 'lint/linter/__tests__/ArcanistMergeConflictLinterTestCase.php',
'ArcanistMissingLinterException' => 'lint/linter/ArcanistMissingLinterException.php',
'ArcanistNoEffectException' => 'exception/usage/ArcanistNoEffectException.php',
'ArcanistNoEngineException' => 'exception/usage/ArcanistNoEngineException.php',
'ArcanistNoLintLinter' => 'lint/linter/ArcanistNoLintLinter.php',
@ -308,6 +309,7 @@ phutil_register_library_map(array(
'ArcanistMercurialParserTestCase' => 'ArcanistTestCase',
'ArcanistMergeConflictLinter' => 'ArcanistLinter',
'ArcanistMergeConflictLinterTestCase' => 'ArcanistArcanistLinterTestCase',
'ArcanistMissingLinterException' => 'Exception',
'ArcanistNoEffectException' => 'ArcanistUsageException',
'ArcanistNoEngineException' => 'ArcanistUsageException',
'ArcanistNoLintLinter' => 'ArcanistLinter',

View file

@ -265,7 +265,7 @@ abstract class ArcanistExternalLinter extends ArcanistFutureLinter {
if ($interpreter) {
if (!Filesystem::binaryExists($interpreter)) {
throw new ArcanistUsageException(
throw new ArcanistMissingLinterException(
pht(
'Unable to locate interpreter "%s" to run linter %s. You may need '.
'to install the interpreter, or adjust your linter configuration.',
@ -273,7 +273,7 @@ abstract class ArcanistExternalLinter extends ArcanistFutureLinter {
get_class($this)));
}
if (!Filesystem::pathExists($binary)) {
throw new ArcanistUsageException(
throw new ArcanistMissingLinterException(
sprintf(
"%s\n%s",
pht(
@ -287,7 +287,7 @@ abstract class ArcanistExternalLinter extends ArcanistFutureLinter {
}
} else {
if (!Filesystem::binaryExists($binary)) {
throw new ArcanistUsageException(
throw new ArcanistMissingLinterException(
sprintf(
"%s\n%s",
pht(

View file

@ -148,7 +148,7 @@ final class ArcanistJSHintLinter extends ArcanistExternalLinter {
if (!is_array($errors)) {
// Something went wrong and we can't decode the output. Exit abnormally.
throw new ArcanistUsageException(
throw new RuntimeException(
"JSHint returned unparseable output.\n".
"stdout:\n\n{$stdout}".
"stderr:\n\n{$stderr}");

View file

@ -0,0 +1,3 @@
<?php
final class ArcanistMissingLinterException extends Exception {}

View file

@ -108,7 +108,7 @@ final class ArcanistPyLintLinter extends ArcanistLinter {
list($err) = exec_manual('which %s', $pylint_bin);
if ($err) {
throw new ArcanistUsageException(
throw new ArcanistMissingLinterException(
"PyLint does not appear to be installed on this system. Install it ".
"(e.g., with 'sudo easy_install pylint') or configure ".
"'lint.pylint.prefix' in your .arcconfig to point to the directory ".

View file

@ -8,7 +8,7 @@ abstract class ArcanistExternalLinterTestCase extends ArcanistLinterTestCase {
$this->assertTrue(
$version !== false,
pht('Failed to parse version from command.'));
} catch (ArcanistUsageException $ex) {
} catch (ArcanistMissingLinterException $ex) {
$this->assertSkipped($ex->getMessage());
}
}

View file

@ -145,13 +145,15 @@ abstract class ArcanistLinterTestCase extends ArcanistPhutilTestCase {
if ($exception instanceof PhutilAggregateException) {
$caught_exception = false;
foreach ($exception->getExceptions() as $ex) {
if ($ex instanceof ArcanistUsageException) {
if ($ex instanceof ArcanistUsageException ||
$ex instanceof ArcanistMissingLinterException) {
$this->assertSkipped($ex->getMessage());
} else {
$caught_exception = true;
}
}
} else if ($exception instanceof ArcanistUsageException) {
} else if ($exception instanceof ArcanistUsageException ||
$exception instanceof ArcanistMissingLinterException) {
$this->assertSkipped($exception->getMessage());
}
$exception_message = $exception->getMessage()."\n\n".