mirror of
https://github.com/morluto/rea.git
synced 2026-10-28 18:35:53 +00:00
Move each error family out of domain/errors.ts into its own module (base, core, provider selection/adapter, browser observation, artifact, evidence, unknown registry, hopper, configuration) and relocate AnalysisErrorProjection to analysisErrorProjection. Migrate all 162 importers to the owning modules and delete errors.ts. No re-export shims; behavior is unchanged.
32 lines
931 B
TypeScript
32 lines
931 B
TypeScript
import { BrowserObservationError } from "../domain/browserObservationError.js";
|
|
import { CdpConnection } from "./CdpConnection.js";
|
|
|
|
/** Execute an optional CDP method while preserving transport and cancellation failures. */
|
|
export const optionalCdpCommand = async (
|
|
context: {
|
|
readonly connection: CdpConnection;
|
|
readonly sessionId: string | undefined;
|
|
readonly signal?: AbortSignal;
|
|
},
|
|
method: string,
|
|
parameters: Readonly<Record<string, unknown>>,
|
|
limitations: string[],
|
|
): Promise<unknown | undefined> => {
|
|
try {
|
|
return await context.connection.send(
|
|
method,
|
|
parameters,
|
|
context.sessionId,
|
|
context.signal,
|
|
);
|
|
} catch (cause: unknown) {
|
|
if (
|
|
!(cause instanceof BrowserObservationError) ||
|
|
cause.reason !== "protocol_error"
|
|
)
|
|
throw cause;
|
|
limitations.push(`${method} was unavailable from this browser target.`);
|
|
return undefined;
|
|
}
|
|
};
|