diff --git a/src/core/contracts/error-handling.ts b/src/core/contracts/error-handling.ts index dbe64f7..6cd32bf 100644 --- a/src/core/contracts/error-handling.ts +++ b/src/core/contracts/error-handling.ts @@ -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; diff --git a/src/handler/events/user-defined.ts b/src/handler/events/user-defined.ts index 082c4ae..a2701ce 100644 --- a/src/handler/events/user-defined.ts +++ b/src/handler/events/user-defined.ts @@ -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) diff --git a/src/handler/id.ts b/src/handler/id.ts index d25b072..c4f95f6 100644 --- a/src/handler/id.ts +++ b/src/handler/id.ts @@ -15,6 +15,7 @@ export function reconstructId(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`; } diff --git a/test/core/services.test.ts b/test/core/services.test.ts index a2dc741..877d425 100644 --- a/test/core/services.test.ts +++ b/test/core/services.test.ts @@ -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?