MCPcopy Create free account
hub / github.com/pingdotgg/t3code / openCodeRuntimeErrorDetail

Function openCodeRuntimeErrorDetail

apps/server/src/provider/opencodeRuntime.ts:68–82  ·  view source on GitHub ↗
(cause: unknown)

Source from the content-addressed store, hash-verified

66}
67
68export function openCodeRuntimeErrorDetail(cause: unknown): string {
69 if (OpenCodeRuntimeError.is(cause)) return cause.detail;
70 if (cause instanceof Error && cause.message.trim().length > 0) return cause.message.trim();
71 if (cause && typeof cause === "object") {
72 // SDK v2 throws { response, request, error? } shapes — extract what's useful
73 const anyCause = cause as Record<string, unknown>;
74 const status = (anyCause.response as { status?: number } | undefined)?.status;
75 const body = anyCause.error ?? anyCause.data ?? anyCause.body;
76 const encodedBody = encodeJsonStringForDiagnostics(body ?? cause);
77 if (encodedBody) {
78 return `status=${status ?? "?"} body=${encodedBody}`;
79 }
80 }
81 return String(cause);
82}
83
84export const runOpenCodeSdk = <A>(
85 operation: string,

Callers 6

toProcessErrorFunction · 0.90
makeOpenCodeAdapterFunction · 0.90
runOpenCodeSdkFunction · 0.85
runOpenCodeCommandFunction · 0.85

Calls 1

Tested by

no test coverage detected