Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat/abstractiti #340

Merged
merged 25 commits into from
Dec 15, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix merge
jacoobes committed Oct 2, 2023
commit e954e2a3997ec09a90fa398ed05f0c6cdba15d60
2 changes: 1 addition & 1 deletion src/core/contracts/error-handling.ts
Original file line number Diff line number Diff line change
@@ -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;
9 changes: 6 additions & 3 deletions src/handlers/event-utils.ts
Original file line number Diff line number Diff line change
@@ -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));
5 changes: 5 additions & 0 deletions src/types/core-modules.ts
Original file line number Diff line number Diff line change
@@ -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;