MCPcopy Create free account
hub / github.com/EmNudge/watlings / formatStackError

Function formatStackError

web-build/src/runner.ts:4–18  ·  view source on GitHub ↗
(err: Error)

Source from the content-addressed store, hash-verified

2import type { ConsoleLine, TestResult } from "./types";
3
4function formatStackError(err: Error): Error | null {
5 const match = err.message.match(
6 /Compiling function #\d+:"([^"]+)" failed: expected (\d+) elements on the stack for fallthru(?:, found (\d+))?/,
7 );
8 if (!match) return null;
9
10 const [, funcName, expected, found] = match;
11 const detail =
12 found === undefined || found === "0"
13 ? `it should return ${expected} value(s) but returns nothing. Add the required WebAssembly instructions to produce the return value.`
14 : `expected ${expected} value(s) on the stack but found ${found}. Check that your instructions produce the correct number of values.`;
15 return new Error(
16 `Function "${funcName}" ${found === undefined || found === "0" ? "is incomplete" : "has a stack mismatch"}: ${detail}`,
17 );
18}
19
20async function instantiate(
21 buffer: Uint8Array,

Callers 1

instantiateFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected