mirror of
https://github.com/sern-handler/handler
synced 2026-06-06 01:16:55 +00:00
chore: make changes in codebase after error contract change
This commit is contained in:
@@ -8,7 +8,8 @@ export interface ErrorHandling {
|
||||
keepAlive: number;
|
||||
|
||||
/**
|
||||
* A function that is called on every crash. Updates keepAlive
|
||||
* A function that is called on every crash. Updates keepAlive.
|
||||
* If keepAlive is 0, the process crashes.
|
||||
* @param error
|
||||
*/
|
||||
updateAlive(error: Error): void;
|
||||
|
||||
@@ -23,9 +23,7 @@ export function makeEventsHandler(
|
||||
case EventType.External:
|
||||
return eventDispatcher(e, Service(e.emitter));
|
||||
default:
|
||||
return err.crash(
|
||||
Error(SernError.InvalidModuleType + ' while creating event handler'),
|
||||
);
|
||||
throw Error(SernError.InvalidModuleType + ' while creating event handler');
|
||||
}
|
||||
};
|
||||
of(null)
|
||||
|
||||
@@ -15,6 +15,7 @@ export function reconstructId<T extends Interaction>(event: T) {
|
||||
case InteractionType.ApplicationCommandAutocomplete: {
|
||||
return `${event.commandName}_A${event.commandType}`;
|
||||
}
|
||||
//Modal interactions are classified as components for sern
|
||||
case InteractionType.ModalSubmit: {
|
||||
return `${event.customId}_C1`;
|
||||
}
|
||||
|
||||
@@ -56,7 +56,14 @@ describe('services', () => {
|
||||
//todo add more
|
||||
it('error-handling', () => {
|
||||
const errorHandler = container.get('@sern/errors');
|
||||
expect(() => errorHandler.crash(new Error("poo"))).toThrowError();
|
||||
const lifetime = errorHandler.keepAlive;
|
||||
for(let i = 0; i< lifetime; i++) {
|
||||
if(i == lifetime-1) {
|
||||
expect(() => errorHandler.updateAlive(new Error("poo"))).toThrowError();
|
||||
} else {
|
||||
expect(() => errorHandler.updateAlive(new Error("poo"))).not.toThrowError();
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
//todo add more, spy on every instance?
|
||||
|
||||
Reference in New Issue
Block a user