diff --git a/renovate.json b/renovate.json index 0eb9306..accfdf1 100644 --- a/renovate.json +++ b/renovate.json @@ -1,5 +1,9 @@ { - "extends": ["config:base", "helpers:pinGitHubActionDigests", "group:allNonMajor"], + "extends": [ + "config:base", + "helpers:pinGitHubActionDigests", + "group:allNonMajor" + ], "major": { "dependencyDashboardApproval": true, "reviewers": ["EvolutionX-10", "jacoobes", "Murtatrxx"] diff --git a/src/core/contracts/error-handling.ts b/src/core/contracts/error-handling.ts index 79d7fe7..ebeb7d4 100644 --- a/src/core/contracts/error-handling.ts +++ b/src/core/contracts/error-handling.ts @@ -1,21 +1,18 @@ +import type { CommandModule,Processed, EventModule } from "../../types/core-modules"; + /** * @since 2.0.0 */ export interface ErrorHandling { - /** - * Number of times the process should throw an error until crashing and exiting - */ - keepAlive: number; - /** * @deprecated * Version 4 will remove this method */ crash(err: Error): never; /** - * A function that is called on every crash. Updates keepAlive. - * If keepAlive is 0, the process crashes. + * A function that is called on every crash. * @param error */ updateAlive(error: Error): void; + } diff --git a/src/core/structures/services/error-handling.ts b/src/core/structures/services/error-handling.ts index f5ef972..3f55b16 100644 --- a/src/core/structures/services/error-handling.ts +++ b/src/core/structures/services/error-handling.ts @@ -3,18 +3,18 @@ import { ErrorHandling } from '../../contracts'; /** * @internal * @since 2.0.0 - * Version 4.0.0 will internalize this api. Please refrain from using ModuleStore! + * Version 4.0.0 will internalize this api. Please refrain from using the defaults! */ export class DefaultErrorHandling implements ErrorHandling { crash(err: Error): never { throw err; } - keepAlive = 5; + #keepAlive = 5; updateAlive(err: Error) { - this.keepAlive--; - if (this.keepAlive === 0) { + this.#keepAlive--; + if (this.#keepAlive === 0) { throw err; } } diff --git a/src/handlers/event-utils.ts b/src/handlers/event-utils.ts index 33cd410..d1f6081 100644 --- a/src/handlers/event-utils.ts +++ b/src/handlers/event-utils.ts @@ -149,6 +149,7 @@ interface ExecutePayload { */ export function executeModule( emitter: Emitter, + errHandler: ErrorHandling, { module, task, @@ -165,7 +166,7 @@ export function executeModule( return EMPTY; } else { if(onError) { - console.log(onError()) + const result = onError() return EMPTY } return throwError(() => SernEmitter.failure(module, result.error)); diff --git a/src/handlers/interaction-event.ts b/src/handlers/interaction-event.ts index 0c385af..70244bd 100644 --- a/src/handlers/interaction-event.ts +++ b/src/handlers/interaction-event.ts @@ -13,7 +13,7 @@ import { import { createInteractionHandler, executeModule, makeModuleExecutor } from './_internal'; import type { DependencyList } from '../types/ioc'; -export function interactionHandler([emitter, , , modules, client]: DependencyList) { +export function interactionHandler([emitter, err , , modules, client]: DependencyList) { const interactionStream$ = sharedEventStream(client, 'interactionCreate'); const handle = createInteractionHandler(interactionStream$, modules); @@ -28,6 +28,6 @@ export function interactionHandler([emitter, , , modules, client]: DependencyLis filterTap(e => emitter.emit('warning', SernEmitter.warning(e))), makeModuleExecutor(module => emitter.emit('module.activate', SernEmitter.failure(module, SernError.PluginFailure))), - concatMap(payload => executeModule(emitter, payload)), + concatMap(payload => executeModule(emitter, err, payload)), ); } diff --git a/src/handlers/message-event.ts b/src/handlers/message-event.ts index 01d7fe0..0ad3b24 100644 --- a/src/handlers/message-event.ts +++ b/src/handlers/message-event.ts @@ -23,7 +23,7 @@ function hasPrefix(prefix: string, content: string) { } export function messageHandler( - [emitter, , log, modules, client]: DependencyList, + [emitter, err, log, modules, client]: DependencyList, defaultPrefix: string | undefined, ) { if (!defaultPrefix) { @@ -42,6 +42,6 @@ export function messageHandler( makeModuleExecutor(module => { emitter.emit('module.activate', SernEmitter.failure(module, SernError.PluginFailure)); }), - concatMap(payload => executeModule(emitter, payload)), + concatMap(payload => executeModule(emitter, err, payload)), ); } diff --git a/tsconfig.json b/tsconfig.json index f7535a7..bbb5bc2 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,8 +3,6 @@ "rootDir": "src", "strict": true, "esModuleInterop": true, - "noImplicitAny": true, - "experimentalDecorators": true, "strictNullChecks": true, "moduleResolution": "node", "skipLibCheck": true,