Closed Bug 1637599 Opened 4 years ago Closed 4 years ago

Simplify propagation of errors with mozilla::Result

Categories

(Core :: MFBT, task)

task

Tracking

()

RESOLVED FIXED
mozilla78
Tracking Status
firefox78 --- fixed

People

(Reporter: sg, Assigned: sg)

Details

Attachments

(2 files)

It would be convenient to be able to write:

Result<T1, E> Func1() {
  Result<T2, E> res = Func2();
  if (res.isErr()) { return res.propagateErr(); }
}

instead of

Result<T1, E> Func1() {
  Result<T2, E> res = Func2();
  if (res.isErr()) { return Err(res.unwrapErr()); }
}

The phrase "copy the error" is misleading, as the error type might not be
copyable, and it is never copied but moved. "Propagate" the error seems to
be a good term to describe this.

Pushed by sgiesecke@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/dbe6c4ba7987
Simplify propagation of error results. r=froydnj
https://hg.mozilla.org/integration/autoland/rev/d469a49a225c
Rephrase documentation referring to copies of errors. r=froydnj
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla78
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: