Skip to content

Commit 90f4f85

Browse files
committed
coderabbit
1 parent 4192b82 commit 90f4f85

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

packages/sdk/src/server/index.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ export class BackendClient extends BaseClient {
271271
return this.ensureValidOauthAccessToken();
272272
}
273273

274-
/**s
274+
/**
275275
* Returns true if the client is configured to use a static access token.
276276
*
277277
* @returns True if the client is configured to use a static access token.
@@ -331,18 +331,17 @@ export class BackendClient extends BaseClient {
331331
if (e instanceof Error) {
332332
errorMessage = e.message;
333333
}
334-
335334
// Check if the error contains response information
336-
if (e && typeof e === 'object' && 'response' in e) {
335+
if (e && typeof e === "object" && "response" in e) {
337336
const errorResponse = (e as any).response;
338337
if (errorResponse) {
339338
statusCode = errorResponse.status;
340-
wwwAuthenticate = errorResponse.headers?.get?.('www-authenticate') ||
341-
errorResponse.headers?.['www-authenticate'];
339+
wwwAuthenticate = errorResponse.headers?.get?.("www-authenticate") ||
340+
errorResponse.headers?.["www-authenticate"];
342341

343342
// Create more specific error message based on status code
344343
if (statusCode === 401) {
345-
errorMessage = `OAuth authentication failed (401 Unauthorized)${wwwAuthenticate ? `: ${wwwAuthenticate}` : ''}`;
344+
errorMessage = `OAuth authentication failed (401 Unauthorized)${wwwAuthenticate ? `: ${wwwAuthenticate}` : ""}`;
346345
} else if (statusCode === 400) {
347346
errorMessage = "OAuth request invalid (400 Bad Request) - check client credentials";
348347
} else if (statusCode) {
@@ -351,11 +350,12 @@ export class BackendClient extends BaseClient {
351350
}
352351
}
353352

354-
// If this is the last attempt, throw a detailed error
353+
const error = new Error(errorMessage);
354+
(error as any).statusCode = statusCode;
355+
(error as any).wwwAuthenticate = wwwAuthenticate;
356+
357+
// If this is the last attempt, throw the error
355358
if (attempts >= maxAttempts) {
356-
const error = new Error(errorMessage);
357-
(error as any).statusCode = statusCode;
358-
(error as any).wwwAuthenticate = wwwAuthenticate;
359359
throw error;
360360
}
361361
}

0 commit comments

Comments
 (0)