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

Function tryOrElse

packages/plugins/mcp/src/sdk/codex-plugins.ts:169–176  ·  view source on GitHub ↗
(evaluate: () => A, orElse: A)

Source from the content-addressed store, hash-verified

167// ---------------------------------------------------------------------------
168
169const tryOrElse = <A>(evaluate: () => A, orElse: A): A => {
170 // oxlint-disable-next-line executor/no-try-catch-or-throw -- boundary: every fs read here is best-effort; a missing or unreadable entry is "not discoverable", not an error
171 try {
172 return evaluate();
173 } catch {
174 return orElse;
175 }
176};
177
178const listDirs = (dir: string): readonly string[] =>
179 tryOrElse(

Callers 5

listDirsFunction · 0.85
readTextFunction · 0.85
isReadableFileFunction · 0.85
isExecutableFileFunction · 0.85
readIconDataUriFunction · 0.85

Calls 1

evaluateFunction · 0.70

Tested by

no test coverage detected