Skip to content

Commit

Permalink
refactor: prefer seat.exit() to seat.fail()
Browse files Browse the repository at this point in the history
- discussion: #9902 (comment)
  • Loading branch information
0xpatrickdev committed Sep 19, 2024
1 parent 41fbac0 commit ea73ef7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/

import { mustMatch } from '@endo/patterns';
import { makeError } from '@endo/errors';
import { makeError, q } from '@endo/errors';
import { makeTracer } from '@agoric/internal';
import { ChainAddressShape } from '../typeGuards.js';

Expand Down Expand Up @@ -77,7 +77,9 @@ export const depositAndDelegate = async (
await contractState.localAccount.transfer(give.Stake, address);
} catch (cause) {
await zoeTools.withdrawToSeat(contractState.localAccount, seat, give);
throw seat.fail(makeError('ibc transfer failed', undefined, { cause }));
const errMsg = makeError(`ibc transfer failed ${q(cause)}`);
seat.exit(errMsg);
throw errMsg;
}
seat.exit();
await account.delegate(validator, give.Stake);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,8 @@ test('start', async t => {
},
);
await t.throwsAsync(vt.when(E(seat).getOfferResult()), {
message: 'ibc transfer failed',
message:
'ibc transfer failed "[Error: simulated unexpected MsgTransfer packet timeout]"',
});
await vt.when(E(seat).hasExited());
const payouts = await E(seat).getPayouts();
Expand Down

0 comments on commit ea73ef7

Please sign in to comment.