MCPcopy
hub / github.com/simstudioai/sim / setupError

Method setupError

packages/testing/src/builders/tool-tester.builder.ts:154–171  ·  view source on GitHub ↗

* Setup error responses for this tool

(errorMessage: string, status = 400)

Source from the content-addressed store, hash-verified

152 * Setup error responses for this tool
153 */
154 setupError(errorMessage: string, status = 400) {
155 this.mockFetch = createErrorFetch(errorMessage, status)
156 global.fetch = Object.assign(this.mockFetch, { preconnect: vi.fn() }) as typeof fetch
157
158 this.error = new Error(errorMessage)
159 ;(this.error as Error & { status: number }).status = status
160
161 if (status > 0) {
162 ;(this.error as Error & { response: unknown }).response = {
163 ok: false,
164 status,
165 statusText: errorMessage,
166 json: () => Promise.resolve({ error: errorMessage, message: errorMessage }),
167 }
168 }
169
170 return this
171 }
172
173 /**
174 * Execute the tool with provided parameters

Callers 1

request.test.tsFile · 0.80

Calls 2

createErrorFetchFunction · 0.85
resolveMethod · 0.65

Tested by

no test coverage detected