Skip to content

Commit

Permalink
Use wrapped error in handle objective request
Browse files Browse the repository at this point in the history
  • Loading branch information
neerajvijay1997 committed Apr 22, 2024
1 parent 41003b5 commit ea97b7c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
23 changes: 16 additions & 7 deletions packages/nitro-node/src/node/engine/engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,7 @@ export class Engine {
try {
chainId = await this.chain.getChainId();
} catch (err) {
return [new EngineEvent({}), new Error(`could not get chain id from chain service: ${err}`)];
return [new EngineEvent({}), new WrappedError(`could not get chain id from chain service: ${err}`, err as Error)];
}

const objectiveId = or.id(myAddress, chainId);
Expand All @@ -746,7 +746,7 @@ export class Engine {
this.store.getConsensusChannel.bind(this.store),
);
} catch (err) {
return [failedEngineEvent, new Error(`handleAPIEvent: Could not create virtualfund objective for ${or}: ${err}`)];
return [failedEngineEvent, new WrappedError(`handleAPIEvent: Could not create virtualfund objective for ${or}: ${err}`, err as Error)];
}

if (METRICS_ENABLED) {
Expand Down Expand Up @@ -784,7 +784,10 @@ export class Engine {
} catch (err) {
return [
failedEngineEvent,
new Error(`handleAPIEvent: Could not create virtualdefund objective for ${JSONbigNative.stringify(request)}: ${err}`),
new WrappedError(
`handleAPIEvent: Could not create virtualdefund objective for ${JSONbigNative.stringify(request)}: ${err}`,
err as Error,
),
];
}
}
Expand All @@ -806,7 +809,10 @@ export class Engine {
} catch (err) {
return [
failedEngineEvent,
new Error(`handleAPIEvent: Could not create virtualdefund objective for ${JSONbigNative.stringify(request)}: ${err}`),
new WrappedError(
`handleAPIEvent: Could not create virtualdefund objective for ${JSONbigNative.stringify(request)}: ${err}`,
err as Error,
),
];
}

Expand All @@ -831,7 +837,7 @@ export class Engine {
} catch (err) {
return [
failedEngineEvent,
new Error(`handleAPIEvent: Could not create directfund objective for ${JSONbigNative.stringify(or)}: ${err}`),
new WrappedError(`handleAPIEvent: Could not create directfund objective for ${JSONbigNative.stringify(or)}: ${err}`, err as Error),
];
}

Expand All @@ -850,7 +856,10 @@ export class Engine {
} catch (err) {
return [
failedEngineEvent,
new Error(`handleAPIEvent: Could not create directdefund objective for ${JSONbigNative.stringify(request)}: ${err}`),
new WrappedError(
`handleAPIEvent: Could not create directdefund objective for ${JSONbigNative.stringify(request)}: ${err}`,
err as Error,
),
];
}

Expand All @@ -863,7 +872,7 @@ export class Engine {
} catch (err) {
return [
failedEngineEvent,
new Error(`handleAPIEvent: Could not destroy consensus channel for ${JSONbigNative.stringify(request)}: ${err}`),
new WrappedError(`handleAPIEvent: Could not destroy consensus channel for ${JSONbigNative.stringify(request)}: ${err}`, err as Error),
];
}

Expand Down
2 changes: 0 additions & 2 deletions packages/server/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,6 @@ const main = async () => {
await new Promise<void>((resolve) => { setTimeout(() => resolve(), 1000); });

await nitro.close();

process.exit(0);
}
};

Expand Down

0 comments on commit ea97b7c

Please sign in to comment.