Commit 5d363cc
authored
Improve serde error output (#982)
In our tests using the serde impl on `Url`, we found that failing URL serialization says the inverse of what it should say.
```toml
[project]
name = "foo"
version = "0.0.0"
dependencies = [
"tqdm ==4.66.0",
]
[tool.uv.sources]
tqdm = { url = "§invalid#+#*Ä" }
```
```
error: Failed to parse: `pyproject.toml`
Caused by: TOML parse error at line 10, column 16
|
10 | tqdm = { url = "§invalid#+#*Ä" }
| ^^^^^^^^^^^^^^^^^
invalid value: string "§invalid#+#*Ä", expected relative URL without a base
```
It says that expected a relative URL without a base, when this was the unexpected input that caused the error. Using `serde::de::Error::custom` oder `serde::de::Error::invalid_value` improves the error message:
```
error: TOML parse error at line 8, column 16
|
8 | tqdm = { url = "§invalid#+#*Ä" }
| ^^^^^^^^^^^^^^^^^
relative URL without a base: "§invalid#+#*Ä"
```1 parent 30e6258 commit 5d363cc
2 files changed
+22
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2700 | 2700 | | |
2701 | 2701 | | |
2702 | 2702 | | |
2703 | | - | |
| 2703 | + | |
2704 | 2704 | | |
2705 | 2705 | | |
2706 | 2706 | | |
| |||
2726 | 2726 | | |
2727 | 2727 | | |
2728 | 2728 | | |
2729 | | - | |
2730 | | - | |
2731 | | - | |
2732 | | - | |
| 2729 | + | |
| 2730 | + | |
2733 | 2731 | | |
2734 | 2732 | | |
2735 | 2733 | | |
| |||
2942 | 2940 | | |
2943 | 2941 | | |
2944 | 2942 | | |
2945 | | - | |
| 2943 | + | |
2946 | 2944 | | |
2947 | 2945 | | |
2948 | 2946 | | |
| |||
2957 | 2955 | | |
2958 | 2956 | | |
2959 | 2957 | | |
2960 | | - | |
2961 | | - | |
2962 | | - | |
2963 | | - | |
| 2958 | + | |
2964 | 2959 | | |
2965 | 2960 | | |
2966 | 2961 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1362 | 1362 | | |
1363 | 1363 | | |
1364 | 1364 | | |
| 1365 | + | |
| 1366 | + | |
| 1367 | + | |
| 1368 | + | |
| 1369 | + | |
| 1370 | + | |
| 1371 | + | |
| 1372 | + | |
| 1373 | + | |
| 1374 | + | |
| 1375 | + | |
| 1376 | + | |
| 1377 | + | |
| 1378 | + | |
| 1379 | + | |
| 1380 | + | |
| 1381 | + | |
0 commit comments