显然throwError(error)现在已被弃用。VS Code 的 IntelliSense 建议throwError(() => new Error('error')。new Error(...)仅接受字符串。在不破坏我的情况下更换它的正确方法是什么HttpErrorHandlerService ?
import { Injectable } from '@angular/core';\nimport {\n HttpEvent,\n HttpInterceptor,\n HttpHandler,\n HttpRequest,\n HttpErrorResponse,\n HttpResponse,\n HttpHeaders\n} from '@angular/common/http';\nimport { Observable, EMPTY, finalize, catchError, timeout, map, throwError } from 'rxjs';\n\nimport { HttpErrorHandlerService } from '@core/services';\n\n@Injectable()\nexport class HttpErrorInterceptor implements HttpInterceptor {\n private readonly APP_XHR_TIMEOUT = 6000;\n\n constructor(private errorHandlerService: HttpErrorHandlerService) {}\n\n intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {\n return next.handle(this.performRequest(request)).pipe(\n timeout(this.APP_XHR_TIMEOUT),\n map((event: HttpEvent<any>) => this.handleSuccessfulResponse(event)),\n catchError((error: …Run Code Online (Sandbox Code Playgroud)