MCPcopy Create free account
hub / github.com/ecomfe/tempad-dev / extractToolErrorCode

Function extractToolErrorCode

packages/mcp-server/src/tools.ts:156–167  ·  view source on GitHub ↗
(error: unknown)

Source from the content-addressed store, hash-verified

154 })
155] as const
156
157function extractToolErrorCode(error: unknown): TempadMcpErrorCode | undefined {
158 const code = getRecordProperty(error, 'code')
159 if (isTempadMcpErrorCode(code)) return code
160 const cause = getRecordProperty(error, 'cause')
161 const causeCode = getRecordProperty(cause, 'code')
162 if (isTempadMcpErrorCode(causeCode)) return causeCode
163 return undefined
164}
165
166function isTempadMcpErrorCode(value: unknown): value is TempadMcpErrorCode {
167 return typeof value === 'string' && KNOWN_ERROR_CODES.has(value)
168}
169
170function extractToolErrorMessage(error: unknown): string {

Callers 1

createToolErrorResponseFunction · 0.85

Calls 1

getRecordPropertyFunction · 0.70

Tested by

no test coverage detected