mirror of
https://github.com/sern-handler/handler
synced 2026-06-06 01:16:55 +00:00
fix merge
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user