Skip to content

Add better handling of Seralization Errors internally #2

@volfco

Description

@volfco

Right now, ZkStruct can blow up if the struct changes; like so:

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error("missing field `resources`", line: 0, column: 0)', /home/colum/.cargo/registry/src/github.com-1ecc6299db9ec823/zkstate-0.1.6/src/lib.rs:249:43
stack backtrace:
   0: rust_begin_unwind
             at /rustc/b3e19a221e63dcffdef87e12eadf1f36a8b90295/library/std/src/panicking.rs:493:5
   1: core::panicking::panic_fmt
             at /rustc/b3e19a221e63dcffdef87e12eadf1f36a8b90295/library/core/src/panicking.rs:92:14
   2: core::option::expect_none_failed
             at /rustc/b3e19a221e63dcffdef87e12eadf1f36a8b90295/library/core/src/option.rs:1329:5
   3: core::result::Result<T,E>::unwrap
             at /home/colum/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/result.rs:1037:23
   4: zkstate::state_change
             at /home/colum/.cargo/registry/src/github.com-1ecc6299db9ec823/zkstate-0.1.6/src/lib.rs:249:17
   5: zkstate::ZkState<T>::initialize
             at /home/colum/.cargo/registry/src/github.com-1ecc6299db9ec823/zkstate-0.1.6/src/lib.rs:90:9
   6: zkstate::ZkState<T>::new
             at /home/colum/.cargo/registry/src/github.com-1ecc6299db9ec823/zkstate-0.1.6/src/lib.rs:71:9
   7: stardance::executor::Executor::new
             at ./stardance/src/executor.rs:43:19
   8: executor::main
             at ./stardance/examples/executor.rs:42:20
   9: core::ops::function::FnOnce::call_once
             at /home/colum/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:227:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

There should be:

  1. better handling of this error so it doesn't panic
  2. documentation around best practices on changing the fields of this object

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions