浏览代码

fix: drop unreachable WebError rethrow in exa/perplexity search

The `if (error instanceof WebError) throw error` guard is dead code in the
exa and perplexity providers: their mappers (mapExaResponse /
mapPerplexityResponse) never throw a WebError — a wrong-shape body throws a
TypeError, which the catch correctly translates to WEB_PROVIDER_ERROR. The
guard was added for symmetry with the deepseek provider, whose mapper DOES
throw a WebError in strict mode (no web_search_tool_result block), so it
keeps the rethrow. The unreachable lines tripped the per-file 100% coverage
gate.
Dudu-0223 3 月之前
父节点
当前提交
bb8f7799ce
共有 2 个文件被更改,包括 0 次插入 和 2 次删除
  1. 0 1
      packages/web/web-search-exa/src/provider.ts
  2. 0 1
      packages/web/web-search-perplexity/src/provider.ts

+ 0 - 1
packages/web/web-search-exa/src/provider.ts

@@ -123,7 +123,6 @@ export class ExaSearchProvider implements WebSearchProvider {
       return mapExaResponse(request.query, payload)
     } catch (error: unknown) {
       if (isAbortError(error)) throw new WebError('Exa search aborted', 'WEB_ABORTED', { cause: error })
-      if (error instanceof WebError) throw error
       throw new WebError(`Exa returned an unprocessable response body: ${String(error)}`, 'WEB_PROVIDER_ERROR', { cause: error })
     }
   }

+ 0 - 1
packages/web/web-search-perplexity/src/provider.ts

@@ -131,7 +131,6 @@ export class PerplexitySearchProvider implements WebSearchProvider {
       return mapPerplexityResponse(request.query, payload)
     } catch (error: unknown) {
       if (isAbortError(error)) throw new WebError('Perplexity search aborted', 'WEB_ABORTED', { cause: error })
-      if (error instanceof WebError) throw error
       throw new WebError(`Perplexity returned an unprocessable response body: ${String(error)}`, 'WEB_PROVIDER_ERROR', { cause: error })
     }
   }