Should load_obj panic on indicies that exceed the bounds of I
theKidOfArcrania opened this issue · comments
Henry Wang commented
If we have an waveform file that has vertex indicies larger than the I
number type that we supply it, we causing a panic, with no chance to potentially catch the error via an Err Result value. Should it return Err instead of hard panicking?
thread 'main' panicked at 'Unable to convert the index from usize', /home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/obj-rs-0.7.1/src/lib.rs:277:30
stack backtrace:
0: rust_begin_unwind
at /rustc/8bdcc62cb0362869f0e7b43a6ae4f96b953d3cbc/library/std/src/panicking.rs:578:5
1: core::panicking::panic_fmt
at /rustc/8bdcc62cb0362869f0e7b43a6ae4f96b953d3cbc/library/core/src/panicking.rs:67:14
2: core::panicking::panic_display
at /rustc/8bdcc62cb0362869f0e7b43a6ae4f96b953d3cbc/library/core/src/panicking.rs:150:5
3: core::panicking::panic_str
at /rustc/8bdcc62cb0362869f0e7b43a6ae4f96b953d3cbc/library/core/src/panicking.rs:134:5
4: core::option::expect_failed
at /rustc/8bdcc62cb0362869f0e7b43a6ae4f96b953d3cbc/library/core/src/option.rs:1952:5
5: core::option::Option<T>::expect
at /rustc/8bdcc62cb0362869f0e7b43a6ae4f96b953d3cbc/library/core/src/option.rs:912:21
6: <obj::TexturedVertex as obj::FromRawVertex<I>>::process::{{closure}}
at /home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/obj-rs-0.7.1/src/lib.rs:276:37
7: <obj::TexturedVertex as obj::FromRawVertex<I>>::process
at /home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/obj-rs-0.7.1/src/lib.rs:294:52
8: obj::Obj<V,I>::new
at /home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/obj-rs-0.7.1/src/lib.rs:71:13
9: obj::load_obj
at /home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/obj-rs-0.7.1/src/lib.rs:52:5
10: rust3d_test::main_with_err
at ./src/main.rs:32:15
11: rust3d_test::main
at ./src/main.rs:40:11
12: core::ops::function::FnOnce::call_once
at /rustc/8bdcc62cb0362869f0e7b43a6ae4f96b953d3cbc/library/core/src/ops/function.rs:250:5
Hyeon Kim (김지현) commented