{"id":17710147,"url":"https://github.com/alexanderthaller/format_serde_error","last_synced_at":"2025-08-21T02:31:22.348Z","repository":{"id":47546765,"uuid":"371424718","full_name":"AlexanderThaller/format_serde_error","owner":"AlexanderThaller","description":"Serde error messages for humans.","archived":false,"fork":false,"pushed_at":"2023-11-26T14:09:18.000Z","size":965,"stargazers_count":34,"open_issues_count":5,"forks_count":8,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-12-14T00:44:03.854Z","etag":null,"topics":["error","formatting","rust","serde"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/format_serde_error","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AlexanderThaller.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-05-27T15:40:47.000Z","updated_at":"2024-05-26T20:48:48.000Z","dependencies_parsed_at":"2024-10-25T12:37:03.124Z","dependency_job_id":null,"html_url":"https://github.com/AlexanderThaller/format_serde_error","commit_stats":{"total_commits":38,"total_committers":4,"mean_commits":9.5,"dds":0.3421052631578947,"last_synced_commit":"b114501c468bfe4f0a8c3f48f84530414bdeeaa1"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexanderThaller%2Fformat_serde_error","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexanderThaller%2Fformat_serde_error/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexanderThaller%2Fformat_serde_error/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexanderThaller%2Fformat_serde_error/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AlexanderThaller","download_url":"https://codeload.github.com/AlexanderThaller/format_serde_error/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230479864,"owners_count":18232630,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["error","formatting","rust","serde"],"created_at":"2024-10-25T06:22:14.721Z","updated_at":"2024-12-19T18:15:20.633Z","avatar_url":"https://github.com/AlexanderThaller.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# format_serde_error\n\n[![Build Status](https://github.com/AlexanderThaller/format_serde_error/workflows/Rust/badge.svg?branch=main)](https://github.com/AlexanderThaller/format_serde_error/actions?query=workflow%3ARusteain)\n[![crates.io](https://img.shields.io/crates/v/format_serde_error.svg)](https://crates.io/crates/format_serde_error)\n[![docs.rs](https://docs.rs/format_serde_error/badge.svg)](https://docs.rs/format_serde_error)\n\nSerde error messages for humans.\n\nFormat serde errors in a way to make it obvious where the error in the source file was.\n\n![\"example serde_json_long output\"](resources/example_output/serde_json_long.png)\n\nAdd this to your Cargo.toml:\n\n```toml\n[dependencies]\nformat_serde_error = \"0.3\"\n```\n\nCurrently [serde_yaml](https://github.com/serde-rs/json),\n[serde_json](https://github.com/dtolnay/serde-yaml) and [toml](https://github.com/alexcrichton/toml-rs) are supported. Extending the\nlibrary to more data types should be relativly easy as long as the errors\nemit a line and column.\n\nAlso has a custom error type which supports printing a message with a given\nline and column (see [examples/custom.rs](examples/custom.rs)).\n\nUsage Example (from [examples/serde_yaml.rs](examples/serde_yaml.rs)):\n\n```rust\nuse format_serde_error::SerdeError;\n\n#[derive(Debug, serde::Serialize, serde::Deserialize)]\nstruct Config {\n    values: Vec\u003cString\u003e,\n}\n\nfn main() -\u003e Result\u003c(), anyhow::Error\u003e {\n    let config_str = \"values:\n  - 'first'\n  - 'second'\n  - third:\";\n\n    let config = serde_yaml::from_str::\u003cConfig\u003e(config_str)\n        .map_err(|err| SerdeError::new(config_str.to_string(), err))?;\n\n    dbg!(config);\n\n    Ok(())\n}\n```\n\nThe output will be:\n\n```\nError:\n   | values:\n   |   - 'first'\n   |   - 'second'\n 4 |   - third:\n   |           ^ values[2]: invalid type: map, expected a string at line 4 column 10\n```\n\n![\"example serde_yaml output\"](resources/example_output/serde_yaml.png)\n\nThe crate will also shorten long lines if necessary (from\n[examples/serde_yaml.rs](examples/serde_yaml.rs)):\n```\nError:\n   | values:\n   |   - 'first'\n   |   - 'second'\n 4 |   - third: Lorem ipsum dolor sit amet, consectetur adipiscing...\n   |           ^ values[2]: invalid type: map, expected a string at line 4 column 10\n```\n\n![\"example serde_yaml output\"](resources/example_output/serde_yaml_long.png)\n\nThe amount of context for lines and characters can be controlled globally and\nper error. See documentation for how to do that. Adding context and shortening\nthe lines can also be disabled.\n\n## Crate Features\n\n### `serde_yaml`\n*Enabled by default:* yes\n\nEnables support for errors emitted by `serde_yaml`.\n\n### `serde_json`\n*Enabled by default:* yes\n\nEnables support for errors emitted by `serde_json`.\n\n### `toml`\n*Enabled by default:* yes\n\nEnables support for errors emitted by `toml`.\n\n### `colored`\n*Enabled by default:* yes\n\nEnables support for color output to a terminal using the `colored` crate.\n\n### `graphemes_support`\n*Enabled by default:* yes\n\nEnables proper support for grapheme cluster when contextualizing long error lines.\n\n## Examples\n\n### serde_json\n![\"example serde_json output\"](resources/example_output/serde_json.png)\n\n### serde_json_long\n![\"example serde_json_long output\"](resources/example_output/serde_json_long.png)\n\n### serde_yaml\n![\"example serde_yaml output\"](resources/example_output/serde_yaml.png)\n\n### serde_yaml_long\n![\"example serde_yaml_long output\"](resources/example_output/serde_yaml_long.png)\n\n### toml\n![\"example toml\"](resources/example_output/toml.png)\n\n### custom\n![\"example custom output\"](resources/example_output/custom.png)\n\n### custom_tabs\n![\"example custom_tabs output\"](resources/example_output/custom_tabs.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexanderthaller%2Fformat_serde_error","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falexanderthaller%2Fformat_serde_error","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexanderthaller%2Fformat_serde_error/lists"}