Currently the following code crashes if an error occurs:
llvm::Expected<Foo> MaybeFoo = ... if (!MaybeFoo) llvm::errs() << formatv("Error: {0}", MaybeFoo.takeError());
I feel conflicted about adding a special case like this, but
- Error has an unusual API that interacts strangely with other libraries.
- it's fairly important, and
- it gets used conditionally on error-handling paths that are rarely tested.
The main alternative I can see is to remove operator<< from Error again.
This requires you to write formatv(..., llvm::toString(MaybeFoo.takeError())),
and provides no way of printing an error by reference.