MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / innerToolError

Function innerToolError

packages/plugins/apps/src/plugin/apps-plugin.ts:61–96  ·  view source on GitHub ↗
(
  cause: unknown,
)

Source from the content-addressed store, hash-verified

59}
60
61const innerToolError = (
62 cause: unknown,
63): { readonly address: string; readonly innerMessage: string; readonly code?: string } | null => {
64 const direct =
65 Predicate.isTagged("AppInnerToolError")(cause) && typeof cause === "object" && cause !== null
66 ? (cause as {
67 readonly address?: unknown;
68 readonly innerMessage?: unknown;
69 readonly code?: unknown;
70 })
71 : null;
72 const nested =
73 direct === null &&
74 cause !== null &&
75 typeof cause === "object" &&
76 "cause" in cause &&
77 Predicate.isTagged("AppInnerToolError")(cause.cause)
78 ? (cause.cause as {
79 readonly address?: unknown;
80 readonly innerMessage?: unknown;
81 readonly code?: unknown;
82 })
83 : direct;
84 if (
85 nested === null ||
86 typeof nested.address !== "string" ||
87 typeof nested.innerMessage !== "string"
88 ) {
89 return null;
90 }
91 return {
92 address: nested.address,
93 innerMessage: nested.innerMessage,
94 ...(typeof nested.code === "string" ? { code: nested.code } : {}),
95 };
96};
97
98const slugify = (value: string): string =>
99 value

Callers 1

makeAppsPluginFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected