]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Improve the handling of `.arclint` files.
authorJoshua Spence <josh@joshuaspence.com>
Mon, 23 Jun 2014 23:24:30 +0000 (09:24 +1000)
committerJoshua Spence <josh@joshuaspence.com>
Mon, 23 Jun 2014 23:24:30 +0000 (09:24 +1000)
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

src/lint/engine/ArcanistConfigurationDrivenLintEngine.php

index 709909e63463d907deec2f27ece3e387e15ceb02..e812f4dec788daea1e620cc5f0e03e3a99f566ed 100644 (file)
@@ -13,11 +13,16 @@ final class ArcanistConfigurationDrivenLintEngine extends ArcanistLintEngine {
     }
 
     $data = Filesystem::readFile($config_path);
-    $config = json_decode($data, true);
-    if (!is_array($config)) {
-      throw new Exception(
-        "Expected '.arclint' file to be a valid JSON file, but failed to ".
-        "decode it: {$config_path}");
+    $config = null;
+    try {
+      $config = phutil_json_decode($data);
+    } catch (PhutilJSONParserException $ex) {
+      throw new PhutilProxyException(
+        pht(
+          "Expected '.arclint' file to be a valid JSON file, but failed to ".
+          "decode %s",
+          $config_path),
+        $ex);
     }
 
     $linters = $this->loadAvailableLinters();