mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-22 14:52:40 +01:00
Improve the handling of .arclint
files.
Summary: Throw a useful error message when an `.arclint` file is not valid JSON. Test Plan: Modified an `.arclint` file to be invalid JSON. ``` > arc lint Exception Parse error on line 24 at column 5: Expected one of: 'EOF', '}', ',', ']' (Run with --trace for a full exception trace.) ``` Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: epriestley, Korvin Differential Revision: https://secure.phabricator.com/D9679
This commit is contained in:
parent
69cd86fa4f
commit
30df78f64c
1 changed files with 10 additions and 5 deletions
|
@ -13,11 +13,16 @@ final class ArcanistConfigurationDrivenLintEngine extends ArcanistLintEngine {
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = Filesystem::readFile($config_path);
|
$data = Filesystem::readFile($config_path);
|
||||||
$config = json_decode($data, true);
|
$config = null;
|
||||||
if (!is_array($config)) {
|
try {
|
||||||
throw new Exception(
|
$config = phutil_json_decode($data);
|
||||||
|
} catch (PhutilJSONParserException $ex) {
|
||||||
|
throw new PhutilProxyException(
|
||||||
|
pht(
|
||||||
"Expected '.arclint' file to be a valid JSON file, but failed to ".
|
"Expected '.arclint' file to be a valid JSON file, but failed to ".
|
||||||
"decode it: {$config_path}");
|
"decode %s",
|
||||||
|
$config_path),
|
||||||
|
$ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
$linters = $this->loadAvailableLinters();
|
$linters = $this->loadAvailableLinters();
|
||||||
|
|
Loading…
Reference in a new issue