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

(Rust) Error Handle: Key Errors immanant #28

Open
TreltaSev opened this issue Aug 2, 2023 · 0 comments
Open

(Rust) Error Handle: Key Errors immanant #28

TreltaSev opened this issue Aug 2, 2023 · 0 comments
Assignees
Labels
-Rust Functionality in Rust bug Something isn't working will implement Will implement this issue or query

Comments

@TreltaSev
Copy link
Owner

From a client to the server, key errors can happen and I need some way to handle those errors.

#[derive(Deserialize)]
struct cstm_type {
    value: String
}

fn foo() {
    let _str_foo = "{\"value\": \"Yes\"}";
    // Fine

    let _str_foo = "{\"other\": \"Yes\"}";
    // Not Fine Will Throw Error
    
    let bar: cstm_type = serde_json::from_str(_str_foo).unwrap();
}

If the json doesnt follow the structure to a T there will be an error, and thats why I need to catch this error.

@TreltaSev TreltaSev added bug Something isn't working will implement Will implement this issue or query -Rust Functionality in Rust labels Aug 2, 2023
@TreltaSev TreltaSev self-assigned this Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
-Rust Functionality in Rust bug Something isn't working will implement Will implement this issue or query
Projects
None yet
Development

No branches or pull requests

1 participant