[PATCH] D104483: Improve error handling in llvm-dwarfdump
James Henderson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 18 00:16:24 PDT 2021
jhenderson added inline comments.
================
Comment at: llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp:274
+static void error(StringRef Prefix, Error Err) {
+ std::error_code EC;
----------------
I think the code would be a lot simpler if you switched which is the "base" error reporting function. If I'm not mistaken, you can use toString to convert an `Error` into an error message. You could convert an error code to an `Error` and report things that way. Approximate code:
```
static void error(StringRef Prefix, Error Err) {
if (!Err)
return;
WithColor::error() << Prefix << ": " << toString(std::move(Err)) << "\n";
exit(1);
}
static void error(StringRef Prefix, std::error_code EC) {
error(errorCodeToError(EC));
}
```
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D104483/new/
https://reviews.llvm.org/D104483
More information about the llvm-commits
mailing list