Skip to content

Commit 6cadf3a

Browse files
committed
telemetry: Move common errors to shared folder
1 parent 32a7bd4 commit 6cadf3a

File tree

4 files changed

+33
-28
lines changed

4 files changed

+33
-28
lines changed

packages/core/src/amazonq/errors.ts

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,6 @@
1111
*/
1212
import { ErrorInformation, ToolkitError } from '../shared/errors'
1313

14-
/**
15-
* Errors extending this class are considered "errors" in service metrics.
16-
*/
17-
export class ClientError extends ToolkitError {
18-
constructor(message: string, info: ErrorInformation = {}) {
19-
super(message, info)
20-
}
21-
}
22-
23-
/**
24-
* Errors extending this class are considered "faults" in service metrics.
25-
*/
26-
export class ServiceError extends ToolkitError {
27-
constructor(message: string, info: ErrorInformation = {}) {
28-
super(message, info)
29-
}
30-
}
31-
3214
/**
3315
* Errors extending this class are considered "LLM failures" in service metrics.
3416
*/
@@ -37,9 +19,3 @@ export class LlmError extends ToolkitError {
3719
super(message, info)
3820
}
3921
}
40-
41-
export class ContentLengthError extends ClientError {
42-
constructor(message: string, info: ErrorInformation = { code: 'ContentLengthError' }) {
43-
super(message, info)
44-
}
45-
}

packages/core/src/amazonqFeatureDev/errors.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,14 @@
66
import { featureName, clientErrorMessages, startTaskAssistLimitReachedMessage } from './constants'
77
import { uploadCodeError } from './userFacingText'
88
import { i18n } from '../shared/i18n-helper'
9-
import { ClientError, LlmError, ServiceError, ContentLengthError as SharedContentLengthError } from '../amazonq/errors'
9+
import { LlmError } from '../amazonq/errors'
1010
import { MetricDataResult } from '../amazonq/commons/types'
11-
import { ToolkitError } from '../shared/errors'
11+
import {
12+
ClientError,
13+
ServiceError,
14+
ContentLengthError as CommonAmazonQContentLengthError,
15+
ToolkitError,
16+
} from '../shared/errors'
1217

1318
export class ConversationIdNotFoundError extends ServiceError {
1419
constructor() {
@@ -104,7 +109,7 @@ export class IllegalStateError extends ServiceError {
104109
}
105110
}
106111

107-
export class ContentLengthError extends SharedContentLengthError {
112+
export class ContentLengthError extends CommonAmazonQContentLengthError {
108113
constructor() {
109114
super(i18n('AWS.amazonq.featureDev.error.contentLengthError'), { code: ContentLengthError.name })
110115
}

packages/core/src/amazonqFeatureDev/session/session.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import { UpdateAnswerMessage } from '../../amazonq/commons/connector/connectorMe
3333
import { FollowUpTypes } from '../../amazonq/commons/types'
3434
import { SessionConfig } from '../../amazonq/commons/session/sessionConfigFactory'
3535
import { Messenger } from '../../amazonq/commons/connector/baseMessenger'
36-
import { ContentLengthError as CommonAmazonQContentLengthError } from '../../amazonq/errors'
36+
import { ContentLengthError as CommonAmazonQContentLengthError } from '../../shared/errors'
3737
export class Session {
3838
private _state?: SessionState | Omit<SessionState, 'uploadId'>
3939
private task: string = ''

packages/core/src/shared/errors.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -826,6 +826,30 @@ export class PermissionsError extends ToolkitError {
826826
}
827827
}
828828

829+
/**
830+
* Errors extending this class are considered "errors" in service metrics.
831+
*/
832+
export class ClientError extends ToolkitError {
833+
constructor(message: string, info: ErrorInformation = { code: '400' }) {
834+
super(message, info)
835+
}
836+
}
837+
838+
/**
839+
* Errors extending this class are considered "faults" in service metrics.
840+
*/
841+
export class ServiceError extends ToolkitError {
842+
constructor(message: string, info: ErrorInformation = { code: '500' }) {
843+
super(message, info)
844+
}
845+
}
846+
847+
export class ContentLengthError extends ClientError {
848+
constructor(message: string, info: ErrorInformation = { code: 'ContentLengthError' }) {
849+
super(message, info)
850+
}
851+
}
852+
829853
export function isNetworkError(err?: unknown): err is Error & { code: string } {
830854
if (!(err instanceof Error)) {
831855
return false

0 commit comments

Comments
 (0)