mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-17 07:45:08 +00:00
editor/code: Assert types in catch in sendRequestWithRetry()
properly
This commit is contained in:
parent
2f6d545535
commit
fd31006646
1 changed files with 12 additions and 8 deletions
|
@ -69,20 +69,24 @@ export async function sendRequestWithRetry<TParam, TRet>(
|
|||
return await (token
|
||||
? client.sendRequest(reqType, param, token)
|
||||
: client.sendRequest(reqType, param));
|
||||
} catch (error) {
|
||||
} catch (error: unknown) {
|
||||
if (delay === null) {
|
||||
log.warn("LSP request timed out", { method: reqType.method, param, error });
|
||||
throw error;
|
||||
}
|
||||
if (error.code === lc.LSPErrorCodes.RequestCancelled) {
|
||||
throw error;
|
||||
|
||||
if (error instanceof lc.ResponseError) {
|
||||
switch (error.code) {
|
||||
case lc.LSPErrorCodes.RequestCancelled:
|
||||
throw error;
|
||||
case lc.LSPErrorCodes.ContentModified:
|
||||
await sleep(delay);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (error.code !== lc.LSPErrorCodes.ContentModified) {
|
||||
log.warn("LSP request failed", { method: reqType.method, param, error });
|
||||
throw error;
|
||||
}
|
||||
await sleep(delay);
|
||||
log.warn("LSP request failed", { method: reqType.method, param, error });
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
throw "unreachable";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue