mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-01 17:39:39 +02:00
Use Predicate and FileSystem in final Effect cleanup
This commit is contained in:
parent
c40bd406f8
commit
976e7ecfc5
6 changed files with 164 additions and 32 deletions
|
|
@ -4,6 +4,7 @@
|
|||
* Python reference: trustgraph-base/trustgraph/exceptions.py
|
||||
*/
|
||||
|
||||
import * as Predicate from "effect/Predicate";
|
||||
import * as S from "effect/Schema";
|
||||
import type { TgError } from "./schema/index.ts";
|
||||
|
||||
|
|
@ -315,8 +316,8 @@ export function flowParameterDecodeError(
|
|||
}
|
||||
|
||||
export function errorMessage(error: unknown): string {
|
||||
if (typeof error === "object" && error !== null && "message" in error) {
|
||||
const message = (error as { message?: unknown }).message;
|
||||
if (Predicate.isObject(error) && Predicate.hasProperty(error, "message")) {
|
||||
const message = error.message;
|
||||
if (typeof message === "string") return message;
|
||||
}
|
||||
return String(error);
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import type { BackendConsumer, PubSubBackend } from "../backend/types.js";
|
|||
import { Flow, type FlowDefinition } from "./flow.js";
|
||||
import { topics } from "../schema/topics.js";
|
||||
import {
|
||||
errorMessage,
|
||||
pubSubError,
|
||||
type FlowRuntimeError,
|
||||
type ProcessorLifecycleError,
|
||||
|
|
@ -282,7 +283,7 @@ export function runFlowProcessorDefinitionScoped<
|
|||
return Effect.void;
|
||||
}
|
||||
return Effect.logError(`[${options.id}] Config consumer error`, {
|
||||
error: error instanceof Error ? error.message : String(error),
|
||||
error: errorMessage(error),
|
||||
}).pipe(
|
||||
Effect.flatMap(() => Effect.sleep(Duration.millis(1000))),
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue