nebius/SWE-bench-extra huggingface dataset:
Repository: patrickfuchs/buildH

Issue:
Be clearer when there is an error with the user supplied json file
Making a try with a toy (user supplied) json file:

```
$ buildH -c 3Conly.pdb -d 3Conly.def -lt Berger_3Conly.json  -l PO3C
usage: buildH [-h] -c COORD [-t TRAJ] -l LIPID [-lt LIPID_TOPOLOGY [LIPID_TOPOLOGY ...]] -d DEFOP [-opx OPDBXTC] [-o OUT]
              [-b BEGIN] [-e END] [-pi PICKLE]
buildH: error: Berger_3Conly.json is in a bad format.
```
This error message is not very precise. The user can't find where the error comes from in the json file.

When doing this by hand:
```
>>> f = open("Berger_3Conly.json")
>>> json.load(f)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/fuchs/software/miniconda3/envs/buildh/lib/python3.9/json/__init__.py", line 293, in load
    return loads(fp.read(),
  File "/home/fuchs/software/miniconda3/envs/buildh/lib/python3.9/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/home/fuchs/software/miniconda3/envs/buildh/lib/python3.9/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/home/fuchs/software/miniconda3/envs/buildh/lib/python3.9/json/decoder.py", line 353, in raw_decode
    obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 4 column 1 (char 61)
```

Here we can see that it comes from line 4 column 1. Easier to debug.
In fact the error was coming from a comma at the end of the last line :

```
{
    "resname": ["PO3C"],
    "C26": ["CH2", "C25", "C27"],
}
```

It makes me think to warn the user about this: don't put a comma on the last line!

Comments:

Patch:
diff --git a/buildh/lipids.py b/buildh/lipids.py
index 7bd1413..3a3a632 100644
--- a/buildh/lipids.py
+++ b/buildh/lipids.py
@@ -46,10 +46,10 @@ def read_lipids_topH(filenames):
             try:
                 topol = json.load(json_file)
             except Exception as e:
-                raise ValueError(f"{filenam_path} is in a bad format.") from e
+                raise ValueError(f"{filenam_path} is in a bad format: " + str(e)) from e
             # make sure at least 'resname' key exists
             if "resname" not in topol:
-                raise ValueError(f"{filenam_path} is in a bad format.")
+                raise ValueError(f"{filenam_path} is in a bad format: keyword 'resname' is missing.")
 
             # Retrieve forcefield and lipid name from the filename
             try:


Test patch:
diff --git a/tests/test_lipids.py b/tests/test_lipids.py
index 3fa0526..cfaa76a 100644
--- a/tests/test_lipids.py
+++ b/tests/test_lipids.py
@@ -54,4 +54,4 @@ class TestLipids():
         bad_file = "Berger_wrongformat.json"
         with pytest.raises(ValueError) as err:
             lipids.read_lipids_topH([PATH_ROOT_DATA / bad_file])
-        assert f"{bad_file} is in a bad format." in str(err.value)
+        assert f"{bad_file} is in a bad format: keyword 'resname' is missing." in str(err.value)