fix merge

This commit is contained in:
Jacob Nguyen
2023-10-02 11:07:13 -05:00
parent f3ed5354eb
commit e954e2a399
3 changed files with 12 additions and 4 deletions

View File

@@ -10,7 +10,7 @@ export interface ErrorHandling {
*/
crash(err: Error): never;
/**
* A function that is called on every crash.
* A function that is called on every throw.
* @param error
*/
updateAlive(error: Error): void;

View File

@@ -30,7 +30,7 @@ import { SernEmitter } from '../core';
import { Err, 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';
import type { AnyModule, CommandModule, ErrorResponse, Module, OnError, Processed } from '../types/core-modules';
import type { ImportPayload } from '../types/core';
function createGenericHandler<Source, Narrowed extends Source, Output>(
@@ -166,8 +166,11 @@ export function executeModule(
return EMPTY;
} else {
if(onError) {
const payload = onError() as CommandError.Response
const err = onError() as CommandError.Response
if(!err) {
return throwError(() =>
SernEmitter.failure(module, "Failed to handle onError: returned nothing"));
}
return EMPTY
}
return throwError(() => SernEmitter.failure(module, result.error));

View File

@@ -21,6 +21,11 @@ import { Awaitable, Args, SlashOptions, SernEventsMapping, AnyFunction } from '.
export type OnError = Record<string, AnyFunction>|undefined
export interface ErrorResponse<T> {
status: 'throw' | 'handle'
body: T
}
export interface CommandMeta {
fullPath: string;
id: string;