I would simplify that to
x = foo() ||| <error case>
<happy case>
(With the specific symbol used in lieu of ||| to be decided)That is shorter and keeps the happy path unindented, even if it has additional such constructs, for example
x = foo() ||| return Error(err, “foo failed”)
y = bar() ||| return Error(err, “bar failed”)