Skip to content

Commit 7209d84

Browse files
committed
refactor(amazonq): addressing code review comments
1 parent d37d443 commit 7209d84

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

server/aws-lsp-codewhisperer/src/language-server/securityScan/codeWhispererSecurityScanServer.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,7 @@ export const SecurityScanServerToken =
196196
logging.log(`Security scan failed. ${error}`)
197197
securityScanTelemetryEntry.result = 'Failed'
198198
const err = getErrorMessage(error)
199-
const exception = hasConnectionExpired(error as Error)
200-
? new AmazonQServiceInvalidConnectionError(err)
201-
: null
199+
const exception = hasConnectionExpired(error) ? new AmazonQServiceInvalidConnectionError(err) : error
202200

203201
return {
204202
status: 'Failed',

server/aws-lsp-codewhisperer/src/shared/amazonQServiceManager/errors.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
// Base error class for Amazon Q
22
export class AmazonQError extends Error {
33
public code: string
4+
override message: string
45
constructor(message: string, code: string) {
56
super(message)
67
this.name = 'AmazonQError'
78
this.code = code
9+
this.message = message
810
}
911
}
1012

@@ -65,10 +67,8 @@ export class AmazonQServiceNoProfileSupportError extends AmazonQError {
6567
}
6668

6769
export class AmazonQServiceInvalidConnectionError extends AmazonQError {
68-
override message: string
6970
constructor(message: string = 'Current authentication token is expired.') {
7071
super(message, 'E_AMAZON_Q_INVALID_CONNECTION')
7172
this.name = 'AmazonQServiceInvalidConnectionError'
72-
this.message = 'Current authentication token is expired.'
7373
}
7474
}

server/aws-lsp-codewhisperer/src/shared/utils.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,10 @@ export function isStringOrNull(object: any): object is string | null {
303303
return typeof object === 'string' || object === null
304304
}
305305

306-
export function hasConnectionExpired(error: Error) {
307-
const authFollowType = getAuthFollowUpType(error)
308-
return authFollowType == 're-auth'
306+
export function hasConnectionExpired(error: any) {
307+
if (error instanceof Error) {
308+
const authFollowType = getAuthFollowUpType(error)
309+
return authFollowType == 're-auth'
310+
}
311+
return false
309312
}

0 commit comments

Comments
 (0)