Skip to content

Commit

Permalink
feat: add strategyName to UnsupportedEventException
Browse files Browse the repository at this point in the history
  • Loading branch information
0xnigir1 committed Nov 14, 2024
1 parent fc23ce3 commit e4a2f63
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ export class UnsupportedEventException extends Error {
constructor(
contract: ContractName,
public readonly eventName: string,
strategyName?: string,
) {
super(`Event ${eventName} unsupported for ${contract} processor`);
super(
`Event ${eventName} unsupported for ${contract} processor${strategyName ? `, strategy ${strategyName}` : ""}`,
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class DirectAllocationStrategyHandler extends BaseStrategyHandler {
this.dependencies,
).handle();
default:
throw new UnsupportedEventException("Strategy", event.eventName);
throw new UnsupportedEventException("Strategy", event.eventName, this.name);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export class DVMDDirectTransferStrategyHandler extends BaseStrategyHandler {
this.dependencies,
).handle();
default:
throw new UnsupportedEventException("Strategy", event.eventName);
throw new UnsupportedEventException("Strategy", event.eventName, this.name);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ describe("DirectAllocationStrategyHandler", () => {
eventName: "UnknownEvent",
} as unknown as ProcessorEvent<"Strategy", StrategyEvent>;

await expect(handler.handle(mockEvent)).rejects.toThrow(UnsupportedEventException);
await expect(handler.handle(mockEvent)).rejects.toThrow(
new UnsupportedEventException("Strategy", "UnknownEvent", handler.name),
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,8 @@ describe("DVMDDirectTransferHandler", () => {
"Strategy",
StrategyEvent
>;
await expect(() => handler.handle(mockEvent)).rejects.toThrow(UnsupportedEventException);
await expect(() => handler.handle(mockEvent)).rejects.toThrow(
new UnsupportedEventException("Strategy", "UnknownEvent", handler.name),
);
});
});

0 comments on commit e4a2f63

Please sign in to comment.