* Setup error responses for this tool
(errorMessage: string, status = 400)
| 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 |
no test coverage detected