[pbs-devel] [PATCH proxmox v3 1/4] CLI: print fatal errors including causes

Gabriel Goller g.goller at proxmox.com
Tue Jun 18 16:21:16 CEST 2024


On 18.06.2024 15:42, Wolfgang Bumiller wrote:
>On Mon, Jun 17, 2024 at 10:12:51AM GMT, Gabriel Goller wrote:
>> From: Fabian Grünbichler <f.gruenbichler at proxmox.com>
>>
>> as a first step of improving our error handling story, printing context
>> and causes if the error contains them.
>>
>> The downside to adding context is that the default Display implementation
>> will *just* print the context, which hides the root cause. This is why
>> we print the errors using the pretty-print formatter in this change.
>>
>> More info in `proxmox-router/README.rst`.
>
>This file will not be seen by anyone. It's also not where I'd expect
>generic coding style advice and doesn't *really* have much to do with
>the router crate.
>
>This info might be better in the developer docs / wiki.

I agree and I'm going to remove this from the next version.

When this is merged where do you think we should put this? I don't think
a new header in
https://pbs.proxmox.com/wiki/index.php/Developer_Documentation is really
fitting. Maybe a new site `Development Best Practices` with 'use context
instead of format_err'? :)

>> diff --git a/proxmox-router/src/cli/command.rs b/proxmox-router/src/cli/command.rs
>> index 7a26ffb9..d5522f12 100644
>> --- a/proxmox-router/src/cli/command.rs
>> +++ b/proxmox-router/src/cli/command.rs
>> @@ -83,7 +83,7 @@ async fn handle_simple_command_future(
>>              }
>>          }
>>          Err(err) => {
>> -            eprintln!("Error: {}", err);
>> +            eprintln!("Error: {:?}", err);
>
>Could go straight to
>
>    eprintln!("Error: {err:?}");
>
>in both cases.

Submitted a v4 already!




More information about the pbs-devel mailing list