MCPcopy
hub / github.com/coder/mux / formatIssuePath

Function formatIssuePath

src/node/orpc/formatOrpcError.ts:233–266  ·  view source on GitHub ↗
(path: StandardSchemaV1.Issue["path"])

Source from the content-addressed store, hash-verified

231}
232
233function formatIssuePath(path: StandardSchemaV1.Issue["path"]): string {
234 if (!path || path.length === 0) {
235 return "<root>";
236 }
237
238 const parts: string[] = [];
239
240 for (const segment of path) {
241 const key =
242 typeof segment === "object" && segment !== null && "key" in segment
243 ? (segment as { key: PropertyKey }).key
244 : segment;
245
246 if (typeof key === "number") {
247 parts.push(`[${key}]`);
248 continue;
249 }
250
251 if (typeof key === "string") {
252 const isIdentifier = /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(key);
253 if (parts.length === 0) {
254 parts.push(isIdentifier ? key : `[${JSON.stringify(key)}]`);
255 } else {
256 parts.push(isIdentifier ? `.${key}` : `[${JSON.stringify(key)}]`);
257 }
258 continue;
259 }
260
261 const rendered = typeof key === "symbol" ? key.toString() : String(key);
262 parts.push(parts.length === 0 ? `[${rendered}]` : `[${rendered}]`);
263 }
264
265 return parts.join("");
266}
267
268function getValidationErrorInfo(
269 cause: unknown

Callers 1

formatOrpcErrorFunction · 0.85

Calls 2

testMethod · 0.80
pushMethod · 0.65

Tested by

no test coverage detected