Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve serde error output #982

Merged
merged 1 commit into from
Oct 28, 2024
Merged

Commits on Oct 18, 2024

  1. Improve serde error output

    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#+#*Ä"
    ```
    konstin committed Oct 18, 2024
    Configuration menu
    Copy the full SHA
    fbe7f5e View commit details
    Browse the repository at this point in the history