Skip to content

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

Merged
davidhewitt merged 1 commit intomainfrom
friendlymatthew/impl-std-error
May 19, 2025
Merged

Impl std::error::Error for error types#205
davidhewitt merged 1 commit intomainfrom
friendlymatthew/impl-std-error

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(())
}

@codecov
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!

@codspeed-hq
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