Error Handling: refactor XlaCoordinator to use status types.#9386
Error Handling: refactor XlaCoordinator to use status types.#9386
XlaCoordinator to use status types.#9386Conversation
|
Should be merged only after #9384. |
3bd1d2c to
1b2ebca
Compare
a351a69 to
7e0da02
Compare
eaac1c3 to
87d2d12
Compare
|
This PR is a draft? Is it ready for review? If yes, please take it out of draft. Thanks! |
|
This is a draft. I'm still working on it. |
510dcce to
a1b26a4
Compare
a78bc1a to
4b71836
Compare
Status and StatusOr<T> QOL functions.XlaCoordinator to use status types.
4b71836 to
55214ac
Compare
61b33fe to
83c3e27
Compare
zhanyong-wan
left a comment
There was a problem hiding this comment.
Hi Yukio, in the future, to make it easier for reviewers to track comments, could you leave the comment threads open so that the reviewers can resolve them after verifying that they are addressed properly? Thanks!
|
@zhanyong-wan @ghpvnist Could you resolve the comments, so that I can merge this once the CI is green? |
@ysiraichi , when the reviewer approves the PR, it means that they trust the author can address the open comments satisfactorily. In that case, you can just resolve open comments yourself after addressing them. Thanks! |
This PR does 3 different things:
StatusandStatusOr<T>constructs, so as to make it easier to propagate non-ok status.XLA_SHOW_CPP_ERROR_CONTEXTenvironment variable for toggling error context.XlaCoordinatorto use the new status propagation constructs as an exampleMainly, inspired by tensorflow implementation, it introduces the following status propagation functions:
XLA_ASSIGN_OR_RETURN(LHS, REXPR, ...), which either assigns the value held byREXPRtoLHSif it holds a non-ok status code, or return the non-ok status.XLA_RETURN_IF_ERROR(EXPR, ...), which early-returns ifEXPRis a non-ok status, propagating the error to the caller.XLA_ERROR_WITH_LOCATION(STATUS), which builds a newabsl::StatusfromSTATUS, by maybe appending the current file locationC++ Error Handling
Idea: by default, print only the user targeted message, with no extra C++ details. Then, by setting the
XLA_SHOW_CPP_ERROR_CONTEXTenvironment variable, also print extra context information, such as C++ source location, and other contextual messages.XLA_ASSIGN_OR_RETURNandXLA_RETURN_IF_ERROR. Rationale: they might have more context to create a more user-friendly message.XLA_SHOW_CPP_ERROR_CONTEXTis set, the callee overwritten error messages are shown in the following linesExample errors:
XLA_SHOW_CPP_ERROR_CONTEXT=0(default):XLA_SHOW_CPP_ERROR_CONTEXT=1: