Skip to content

Impl std::error::Error for error types #205

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

Merged
merged 1 commit into from
May 19, 2025

Conversation

friendlymatthew
Copy link
Member

This commit updates the library error types to implement std::error::Error.

Currently, JiterError and JsonError do not implement std::error::Error. This prevents error chaining and interoperability with standard error handling.

use jiter::JsonValue;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let json_data = r#"
        {
            "name": "John Doe",
            "age": 43,
            "phones": [
                "+44 1234567",
                "+44 2345678"
            ]
        }"#;
    let json_value = JsonValue::parse(json_data.as_bytes(), true)?; // <-- can't do this
    println!("{:#?}", json_value);

    Ok(())
}

Copy link

codecov bot commented May 19, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

📢 Thoughts on this report? Let us know!

Copy link

codspeed-hq bot commented May 19, 2025

CodSpeed Performance Report

Merging #205 will not alter performance

Comparing friendlymatthew/impl-std-error (be24fa1) with main (4f06514)

Summary

✅ 70 untouched benchmarks

Copy link
Collaborator

@davidhewitt davidhewitt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks 👍

@davidhewitt davidhewitt merged commit 961d830 into main May 19, 2025
25 checks passed
@davidhewitt davidhewitt deleted the friendlymatthew/impl-std-error branch May 19, 2025 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants