Michael137 wrote:

> I like the idea of this PR (big fan of `llvm::Expected`) but the way this is 
> implemented contains an anti-pattern IMO. Specifically, all callers consume 
> the error from `ExtractIndexFromString` only to then create a similar but 
> different error string afterwards. It would be great if the callers could 
> just propagate the error from `ExtractIndexFromString` instead of doing this 
> dance.
> 
> Perhaps `ExtractIndexFromString` could return the error string `Type has no 
> child named '%s'` and the function could be named something more descriptive? 
> Something like `ExtractIndexOfChildFromString`?

+1

This is what I was afraid of when we discussed what kind of error we want to 
put into these `Expected` objects 
(https://github.com/llvm/llvm-project/pull/136693#discussion_r2059191615). We 
now have this unwritten rule that forces us to consume the more detailed error. 
What we really want is to consume this error just when we're about to present 
it to the user, so we can swap it for something more reasonable. @adrian-prantl 
suggested that we create an Error object that holds both a 
generic/user-presentable message and the detailed message. I agree with 
@bulbazord that we should bubble the error up for now until we have such an 
object

https://github.com/llvm/llvm-project/pull/138297
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to