From 17eb701b5f68fc0486b5092952ff55d479694914 Mon Sep 17 00:00:00 2001 From: jacob Date: Thu, 2 Nov 2023 14:19:43 -0500 Subject: [PATCH] decide not to support error handling for autocomplete --- src/handlers/dispatchers.ts | 7 ++----- src/handlers/event-utils.ts | 12 ++++++------ 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/handlers/dispatchers.ts b/src/handlers/dispatchers.ts index e111467..4f30f04 100644 --- a/src/handlers/dispatchers.ts +++ b/src/handlers/dispatchers.ts @@ -83,15 +83,12 @@ export function createDispatcher(payload: { option, Error(SernError.NotSupportedInteraction + ` There is no autocomplete tag for this option`), ); - const { command, name, parent } = option; - const resolvedErrorHandler = parent - ? 'option:'+parent+':'+name - : 'option:'+name + const { command } = option; return { ...payload, module: command as Processed, //autocomplete is not a true "module" warning cast! args: [payload.event], - onError: payload.onError?.[resolvedErrorHandler] + onError: undefined }; } return { diff --git a/src/handlers/event-utils.ts b/src/handlers/event-utils.ts index 3c2ac52..7403c5c 100644 --- a/src/handlers/event-utils.ts +++ b/src/handlers/event-utils.ts @@ -27,7 +27,7 @@ import { CommandError, Emitter, ErrorHandling, Logging, ModuleManager } from '.. import { contextArgs, createDispatcher } from './dispatchers'; import { ObservableInput, pipe } from 'rxjs'; import { SernEmitter } from '../core'; -import { Err, Ok, Result } from 'ts-results-es'; +import { Err, ErrImpl, Ok, Result } from 'ts-results-es'; import type { AnyFunction, Awaitable } from '../types/utility'; import type { ControlPlugin } from '../types/core-plugin'; import type { AnyModule, CommandModule, Module, OnError, Processed } from '../types/core-modules'; @@ -159,7 +159,7 @@ export function executeModule( args }: ExecutePayload, ) { - const onError$ = (err) => { + const onError$ = (err_msg: unknown) => { if(!onError) { return throwError(() => SernEmitter.failure(module, err)); } @@ -177,12 +177,12 @@ export function executeModule( const apiObject = args[0]; assert(apiObject && typeof apiObject === 'object', "Args[0] was falsy while trying to create onError"); assert(err.body, "Body of error response cannot be empty"); + if('respond' in apiObject && typeof apiObject.respond === 'function') { + return throwError(() => SernEmitter.failure(module, "Cannot handle autocomplete errors")); + } if('reply' in apiObject && typeof apiObject.reply === 'function') { return from(apiObject.reply(err.body)) - } - if('respond' in apiObject && typeof apiObject.respond === 'function') { - return from(apiObject.respond(err.body)) - } + } return EMPTY; }