Print the OS error's text once, the way read_premises does
This commit is contained in:
+1
-1
@@ -222,7 +222,7 @@ def trust(paths):
|
|||||||
with open(config, encoding="utf-8") as handle:
|
with open(config, encoding="utf-8") as handle:
|
||||||
data = json.load(handle)
|
data = json.load(handle)
|
||||||
except (OSError, ValueError) as failure:
|
except (OSError, ValueError) as failure:
|
||||||
print(f"could not read {config}: {failure}", file=sys.stderr)
|
print(f"could not read {config}: {getattr(failure, 'strerror', failure)}", file=sys.stderr)
|
||||||
return
|
return
|
||||||
projects = data.setdefault("projects", {})
|
projects = data.setdefault("projects", {})
|
||||||
granted = [path for path in paths if not projects.get(path, {}).get("hasTrustDialogAccepted")]
|
granted = [path for path in paths if not projects.get(path, {}).get("hasTrustDialogAccepted")]
|
||||||
|
|||||||
@@ -206,8 +206,7 @@ class Trust(unittest.TestCase):
|
|||||||
config = pathlib.Path(home, ".claude.json")
|
config = pathlib.Path(home, ".claude.json")
|
||||||
with contextlib.redirect_stderr(io.StringIO()) as err:
|
with contextlib.redirect_stderr(io.StringIO()) as err:
|
||||||
loop.trust(["/a"])
|
loop.trust(["/a"])
|
||||||
self.assertIn(f"could not read {config}: ", err.getvalue())
|
self.assertEqual(err.getvalue(), f"could not read {config}: No such file or directory\n")
|
||||||
self.assertIn("No such file or directory", err.getvalue())
|
|
||||||
config.write_text("{")
|
config.write_text("{")
|
||||||
with contextlib.redirect_stderr(io.StringIO()) as err:
|
with contextlib.redirect_stderr(io.StringIO()) as err:
|
||||||
loop.trust(["/a"])
|
loop.trust(["/a"])
|
||||||
|
|||||||
Reference in New Issue
Block a user