-
Notifications
You must be signed in to change notification settings - Fork 60
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
Handle errors gracefully in main() #99
Comments
I can help with this |
Handle calls to VMM::try_from() or vmm.run(). This commit adds anyhow and thiserror crates to handle errors. The `anyhow` crate is used in the main binary to add extra context and give a pretty view of error trace. The create `thiserror` was used to easily derive `std::error::Error` for errors provided by libs. The new crates pulls the following extra crates: ```diff +name = "proc-macro2" +name = "quote" +name = "syn" +name = "thiserror-impl" +name = "unicode-xid" ``` New error format: examples: ```sh $ vmm-reference --kernel \ path=/path/vmlinuz-5.10.25 Error: Failed to create VMM from configurations Caused by: Error issuing an ioctl to KVM. $ echo $? 1 ``` ```sh $ vmm-reference --kernel path Error: Failed to parse CLI options Caused by: Failed to parse cli Invalid input for kernel: Missing required argument: path ``` ``` $vmm-reference Error: Failed to parse CLI options Caused by: Failed to parse cli error: The following required arguments were not provided: --kernel <kernel> USAGE: vmm-reference [OPTIONS] --kernel <kernel> For more information try --help ``` Fixes: rust-vmm#99 Signed-off-by: Carlos Venegas <[email protected]>
Handle calls to VMM::try_from() or vmm.run(). This commit adds anyhow and thiserror crates to handle errors. The `anyhow` crate is used in the main binary to add extra context and give a pretty view of error trace. The create `thiserror` was used to easily derive `std::error::Error` for errors provided by libs. The new crates pulls the following extra crates: ```diff +name = "proc-macro2" +name = "quote" +name = "syn" +name = "thiserror-impl" +name = "unicode-xid" ``` New error format: examples: ```sh $ vmm-reference --kernel \ path=/path/vmlinuz-5.10.25 Error: Failed to create VMM from configurations Caused by: Error issuing an ioctl to KVM. $ echo $? 1 ``` ```sh $ vmm-reference --kernel path Error: Failed to parse CLI options Caused by: Failed to parse cli Invalid input for kernel: Missing required argument: path ``` ``` $vmm-reference Error: Failed to parse CLI options Caused by: Failed to parse cli error: The following required arguments were not provided: --kernel <kernel> USAGE: vmm-reference [OPTIONS] --kernel <kernel> For more information try --help ``` Fixes: rust-vmm#99 Signed-off-by: Carlos Venegas <[email protected]>
Handle calls to VMM::try_from() or vmm.run(). This commit adds anyhow and thiserror crates to handle errors. The `anyhow` crate is used in the main binary to add extra context and give a pretty view of error trace. The create `thiserror` was used to easily derive `std::error::Error` for errors provided by libs. The new crates pulls the following extra crates: ```diff +name = "proc-macro2" +name = "quote" +name = "syn" +name = "thiserror-impl" +name = "unicode-xid" ``` New error format: examples: ```sh $ vmm-reference --kernel \ path=/path/vmlinuz-5.10.25 Error: Failed to create VMM from configurations Caused by: Error issuing an ioctl to KVM. $ echo $? 1 ``` ```sh $ vmm-reference --kernel path Error: Failed to parse CLI options Caused by: Failed to parse cli Invalid input for kernel: Missing required argument: path ``` ``` $vmm-reference Error: Failed to parse CLI options Caused by: Failed to parse cli error: The following required arguments were not provided: --kernel <kernel> USAGE: vmm-reference [OPTIONS] --kernel <kernel> For more information try --help ``` Fixes: rust-vmm#99 Signed-off-by: Carlos Venegas <[email protected]>
Handle calls to `CLI`, `VMM::try_from()` and `vmm.run()`. This commit adds anyhow and thiserror crates to handle errors. The `anyhow` crate is used in the main binary to add extra context and give a pretty view of error trace. The create `thiserror` was used to easily derive `std::error::Error` for errors provided by libs. The new crates pulls the following extra crates: ```diff +name = "proc-macro2" +name = "quote" +name = "syn" +name = "thiserror-impl" +name = "unicode-xid" ``` New error format: examples: ```sh $ vmm-reference --kernel \ path=/path/vmlinuz-5.10.25 Error: Failed to create VMM from configurations Caused by: Error issuing an ioctl to KVM. $ echo $? 1 ``` ```sh $ vmm-reference --kernel path Error: Failed to parse CLI options Caused by: Failed to parse cli Invalid input for kernel: Missing required argument: path ``` ``` $vmm-reference Error: Failed to parse CLI options Caused by: Failed to parse cli error: The following required arguments were not provided: --kernel <kernel> USAGE: vmm-reference [OPTIONS] --kernel <kernel> For more information try --help ``` Fixes: rust-vmm#99 Signed-off-by: Carlos Venegas <[email protected]>
Handle calls to `CLI`, `VMM::try_from()` and `vmm.run()`. This commit adds anyhow and thiserror crates to handle errors. The `anyhow` crate is used in the main binary to add extra context and give a pretty view of error trace. The create `thiserror` was used to easily derive `std::error::Error` for errors provided by libs. The new crates pulls the following extra crates: ```diff +name = "proc-macro2" +name = "quote" +name = "syn" +name = "thiserror-impl" +name = "unicode-xid" ``` New error format: examples: ```sh $ vmm-reference --kernel \ path=/path/vmlinuz-5.10.25 Error: Failed to create VMM from configurations Caused by: Error issuing an ioctl to KVM. $ echo $? 1 ``` ```sh $ vmm-reference --kernel path Error: Failed to parse CLI options Caused by: Failed to parse cli Invalid input for kernel: Missing required argument: path ``` ``` $vmm-reference Error: Failed to parse CLI options Caused by: Failed to parse cli error: The following required arguments were not provided: --kernel <kernel> USAGE: vmm-reference [OPTIONS] --kernel <kernel> For more information try --help ``` Fixes: rust-vmm#99 Signed-off-by: Carlos Venegas <[email protected]>
Handle calls to `CLI`, `VMM::try_from()` and `vmm.run()`. This commit adds anyhow and thiserror crates to handle errors. The `anyhow` crate is used in the main binary to add extra context and give a pretty view of error trace. The create `thiserror` was used to easily derive `std::error::Error` for errors provided by libs. The new crates pulls the following extra crates: ```diff +name = "proc-macro2" +name = "quote" +name = "syn" +name = "thiserror-impl" +name = "unicode-xid" ``` New error format: examples: ```sh $ vmm-reference --kernel \ path=/path/vmlinuz-5.10.25 Error: Failed to create VMM from configurations Caused by: Error issuing an ioctl to KVM. $ echo $? 1 ``` ```sh $ vmm-reference --kernel path Error: Failed to parse CLI options Caused by: Failed to parse cli Invalid input for kernel: Missing required argument: path ``` ``` $vmm-reference Error: Failed to parse CLI options Caused by: Failed to parse cli error: The following required arguments were not provided: --kernel <kernel> USAGE: vmm-reference [OPTIONS] --kernel <kernel> For more information try --help ``` Fixes: rust-vmm#99 Signed-off-by: Carlos Venegas <[email protected]>
Handle calls to `CLI`, `VMM::try_from()` and `vmm.run()`. This commit adds anyhow and thiserror crates to handle errors. The `anyhow` crate is used in the main binary to add extra context and give a pretty view of error trace. The create `thiserror` was used to easily derive `std::error::Error` for errors provided by libs. The new crates pulls the following extra crates: ```diff +name = "proc-macro2" +name = "quote" +name = "syn" +name = "thiserror-impl" +name = "unicode-xid" ``` New error format: examples: ```sh $ vmm-reference --kernel \ path=/path/vmlinuz-5.10.25 Error: Failed to create VMM from configurations Caused by: Error issuing an ioctl to KVM. $ echo $? 1 ``` ```sh $ vmm-reference --kernel path Error: Failed to parse CLI options Caused by: Failed to parse cli Invalid input for kernel: Missing required argument: path ``` ``` $vmm-reference Error: Failed to parse CLI options Caused by: Failed to parse cli error: The following required arguments were not provided: --kernel <kernel> USAGE: vmm-reference [OPTIONS] --kernel <kernel> For more information try --help ``` Fixes: rust-vmm#99 Signed-off-by: Carlos Venegas <[email protected]>
Handle calls to `CLI`, `VMM::try_from()` and `vmm.run()`. This commit adds anyhow and thiserror crates to handle errors. The `anyhow` crate is used in the main binary to add extra context and give a pretty view of error trace. The create `thiserror` was used to easily derive `std::error::Error` for errors provided by libs. The new crates pulls the following extra crates: ```diff +name = "proc-macro2" +name = "quote" +name = "syn" +name = "thiserror-impl" +name = "unicode-xid" ``` New error format: examples: ```sh $ vmm-reference --kernel \ path=/path/vmlinuz-5.10.25 Error: Failed to create VMM from configurations Caused by: Error issuing an ioctl to KVM. $ echo $? 1 ``` ```sh $ vmm-reference --kernel path Error: Failed to parse CLI options Caused by: Failed to parse cli Invalid input for kernel: Missing required argument: path ``` ``` $vmm-reference Error: Failed to parse CLI options Caused by: Failed to parse cli error: The following required arguments were not provided: --kernel <kernel> USAGE: vmm-reference [OPTIONS] --kernel <kernel> For more information try --help ``` Fixes: rust-vmm#99 Signed-off-by: Carlos Venegas <[email protected]>
I have opened #122 , there I add some error handling using two external crates, |
Hi, @jcvenegas! You're right, we are indeed trying to limit the number of external dependencies. I think it should be fine to just handle the unwraps, without adding |
@lauralt I will send a second PR as al alternative proposal |
We are currently panicking if
VMM::try_from()
orvmm.run()
fail. We could instead handle those errors gracefully (by logging an error, exiting the process etc.).The text was updated successfully, but these errors were encountered: