feat(core-shared/instrumentation): withCapture returns Captured<F>

This commit is contained in:
2026-05-12 21:32:42 +02:00
parent 5ac668497f
commit a1fbd16d83
2 changed files with 15 additions and 3 deletions

View File

@@ -1,4 +1,5 @@
import type { ILogger } from "./logger.interface";
import type { Captured } from "../conformance/brands";
import { isReported, markReported } from "./reported-flag";
/**
@@ -25,8 +26,8 @@ export function withCapture<Args extends unknown[], R>(
logger: ILogger,
tags: Record<string, string>,
fn: (...args: Args) => Promise<R>,
): (...args: Args) => Promise<R> {
return async (...args) => {
): Captured<(...args: Args) => Promise<R>> {
const wrapped: (...args: Args) => Promise<R> = async (...args) => {
try {
return await fn(...args);
} catch (err) {
@@ -37,4 +38,5 @@ export function withCapture<Args extends unknown[], R>(
throw err;
}
};
return wrapped as Captured<(...args: Args) => Promise<R>>;
}