Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15353962
D9681.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
D9681.diff
View Options
diff --git a/src/configuration/ArcanistConfigurationManager.php b/src/configuration/ArcanistConfigurationManager.php
--- a/src/configuration/ArcanistConfigurationManager.php
+++ b/src/configuration/ArcanistConfigurationManager.php
@@ -63,13 +63,13 @@
}
/**
- * For the advanced case where you want customized configuratin handling.
+ * For the advanced case where you want customized configuration handling.
*
* Reads the configuration from all available sources, returning a map (array)
* of results, with the source as key. Missing values will not be in the map,
* so an empty array will be returned if no results are found.
*
- * The map is ordered by the cannonical sources precedence, which is:
+ * The map is ordered by the canonical sources precedence, which is:
* runtime > local > project > user > system
*
* @param key Key to read
@@ -198,10 +198,12 @@
}
$user_config_data = Filesystem::readFile($user_config_path);
- $user_config = json_decode($user_config_data, true);
- if (!is_array($user_config)) {
- throw new ArcanistUsageException(
- "Your '~/.arcrc' file is not a valid JSON file.");
+ try {
+ $user_config = phutil_json_decode($user_config_data);
+ } catch (PhutilJSONParserException $ex) {
+ throw new PhutilProxyException(
+ "Your '~/.arcrc' file is not a valid JSON file.".
+ $ex);
}
} else {
$console->writeLog(
@@ -290,8 +292,14 @@
'Config: Reading system configuration file "%s"...',
$system_config_path));
$file = Filesystem::readFile($system_config_path);
- if ($file) {
- $system_config = json_decode($file, true);
+ try {
+ $system_config = phutil_json_decode($file);
+ } catch (PhutilJSONParserException $ex) {
+ throw new PhutilProxyException(
+ pht(
+ "Your '%s' file is not a valid JSON file.",
+ $system_config_path),
+ $ex);
}
} else {
$console->writeLog(
@@ -324,7 +332,7 @@
return $this->runtimeConfig;
}
- public function readDefaultConfig() {
+ public function readDefaultConfig() {
$settings = new ArcanistSettings();
return $settings->getDefaultSettings();
}
diff --git a/src/workingcopyidentity/ArcanistWorkingCopyIdentity.php b/src/workingcopyidentity/ArcanistWorkingCopyIdentity.php
--- a/src/workingcopyidentity/ArcanistWorkingCopyIdentity.php
+++ b/src/workingcopyidentity/ArcanistWorkingCopyIdentity.php
@@ -201,17 +201,13 @@
}
private static function parseRawConfigFile($raw_config, $from_where) {
- $proj = json_decode($raw_config, true);
-
- if (!is_array($proj)) {
- throw new Exception(
- "Unable to parse '.arcconfig' file '{$from_where}'. The file contents ".
- "should be valid JSON.\n\n".
- "FILE CONTENTS\n".
- substr($raw_config, 0, 2048));
+ try {
+ return phutil_json_decode($raw_config);
+ } catch (PhutilJSONParserException $ex) {
+ throw new PhutilProxyException(
+ pht("Unable to parse '.arcconfig' file '%s'.", $from_where),
+ $ex);
}
-
- return $proj;
}
private function __construct($root, array $config) {
@@ -297,15 +293,13 @@
*
* @task config
*/
- public function getLocalConfig($key, $default=null) {
+ public function getLocalConfig($key, $default = null) {
return idx($this->localConfig, $key, $default);
}
public function readLocalArcConfig() {
if (strlen($this->localMetaDir)) {
- $local_path = Filesystem::resolvePath(
- 'arc/config',
- $this->localMetaDir);
+ $local_path = Filesystem::resolvePath('arc/config', $this->localMetaDir);
$console = PhutilConsole::getConsole();
@@ -316,9 +310,12 @@
'Config: Reading local configuration file "%s"...',
$local_path));
- $file = Filesystem::readFile($local_path);
- if ($file) {
- return json_decode($file, true);
+ try {
+ return phutil_json_decode($local_path);
+ } catch (PhutilJSONParserException $ex) {
+ throw new PhutilProxyException(
+ pht("Failed to parse '%s' as JSON.", $local_path),
+ $ex);
}
} else {
$console->writeLog(
@@ -327,8 +324,8 @@
'Config: Did not find local configuration at "%s".',
$local_path));
}
-
}
+
return array();
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Mar 12, 1:14 AM (4 h, 7 m ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7524396
Default Alt Text
D9681.diff (4 KB)
Attached To
Mode
D9681: Better handling of `.arcconfig` files.
Attached
Detach File
Event Timeline
Log In to Comment