}
protected function parseLinterOutput($path, $err, $stdout, $stderr) {
- $errors = json_decode($stdout, true);
-
- if (!is_array($errors)) {
+ $errors = null;
+ try {
+ $error = phutil_json_decode($stdout);
+ } catch (PhutilJSONParserException $ex) {
// Something went wrong and we can't decode the output. Exit abnormally.
- throw new RuntimeException(
- "JSHint returned unparseable output.\n".
- "stdout:\n\n{$stdout}".
- "stderr:\n\n{$stderr}");
+ throw new PhutilProxyException(
+ pht('JSHint returned unparseable output.'),
+ $ex);
}
$messages = array();
$json = preg_replace('/}{\s*"/', '},{"', $json);
$json = '['.$json.']';
- $json = json_decode($json);
- if (!is_array($json)) {
- throw new Exception('JSON could not be decoded');
- }
-
- return $json;
+ return phutil_json_decode($json);
}
}
pht('Waiting for JSON parameters on stdin...'));
}
$params = @file_get_contents('php://stdin');
- $params = json_decode($params, true);
- if (!is_array($params)) {
+ try {
+ $params = phutil_json_decode($params);
+ } catch (PhutilJSONParserException $ex) {
throw new ArcanistUsageException(
pht('Provide method parameters on stdin as a JSON blob.'));
}