Skip to content

Commit 7d2182f

Browse files
committed
feat(clients): throw exceptions as ServiceException class
1 parent 030da71 commit 7d2182f

File tree

929 files changed

+182290
-448636
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

929 files changed

+182290
-448636
lines changed

clients/client-accessanalyzer/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ export * from "./AccessAnalyzer";
22
export * from "./AccessAnalyzerClient";
33
export * from "./commands";
44
export * from "./models";
5+
export { ServiceException } from "@aws-sdk/smithy-client";
56
export * from "./pagination";

clients/client-accessanalyzer/src/models/models_0.ts

Lines changed: 122 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,34 @@
1-
import { MetadataBearer as $MetadataBearer, SmithyException as __SmithyException } from "@aws-sdk/types";
1+
import {
2+
ExceptionOptionType as __ExceptionOptionType,
3+
ServiceException as __BaseException,
4+
} from "@aws-sdk/smithy-client";
5+
import { MetadataBearer as $MetadataBearer } from "@aws-sdk/types";
26

37
/**
48
* <p>You do not have sufficient access to perform this action.</p>
59
*/
6-
export interface AccessDeniedException extends __SmithyException, $MetadataBearer {
7-
name: "AccessDeniedException";
8-
$fault: "client";
9-
message: string | undefined;
10+
export class AccessDeniedException extends __BaseException {
11+
readonly name: "AccessDeniedException" = "AccessDeniedException";
12+
readonly $fault: "client" = "client";
13+
/**
14+
* @internal
15+
*/
16+
constructor(opts: __ExceptionOptionType<AccessDeniedException, __BaseException>) {
17+
super({
18+
name: "AccessDeniedException",
19+
$fault: "client",
20+
...opts,
21+
});
22+
Object.setPrototypeOf(this, AccessDeniedException.prototype);
23+
}
1024
}
1125

1226
/**
1327
* <p>A conflict exception error.</p>
1428
*/
15-
export interface ConflictException extends __SmithyException, $MetadataBearer {
16-
name: "ConflictException";
17-
$fault: "client";
18-
message: string | undefined;
29+
export class ConflictException extends __BaseException {
30+
readonly name: "ConflictException" = "ConflictException";
31+
readonly $fault: "client" = "client";
1932
/**
2033
* <p>The ID of the resource.</p>
2134
*/
@@ -25,6 +38,20 @@ export interface ConflictException extends __SmithyException, $MetadataBearer {
2538
* <p>The resource type.</p>
2639
*/
2740
resourceType: string | undefined;
41+
42+
/**
43+
* @internal
44+
*/
45+
constructor(opts: __ExceptionOptionType<ConflictException, __BaseException>) {
46+
super({
47+
name: "ConflictException",
48+
$fault: "client",
49+
...opts,
50+
});
51+
Object.setPrototypeOf(this, ConflictException.prototype);
52+
this.resourceId = opts.resourceId;
53+
this.resourceType = opts.resourceType;
54+
}
2855
}
2956

3057
/**
@@ -98,24 +125,35 @@ export namespace CreateArchiveRuleRequest {
98125
/**
99126
* <p>Internal server error.</p>
100127
*/
101-
export interface InternalServerException extends __SmithyException, $MetadataBearer {
102-
name: "InternalServerException";
103-
$fault: "server";
104-
$retryable: {};
105-
message: string | undefined;
128+
export class InternalServerException extends __BaseException {
129+
readonly name: "InternalServerException" = "InternalServerException";
130+
readonly $fault: "server" = "server";
131+
$retryable = {};
106132
/**
107133
* <p>The seconds to wait to retry.</p>
108134
*/
109135
retryAfterSeconds?: number;
136+
137+
/**
138+
* @internal
139+
*/
140+
constructor(opts: __ExceptionOptionType<InternalServerException, __BaseException>) {
141+
super({
142+
name: "InternalServerException",
143+
$fault: "server",
144+
...opts,
145+
});
146+
Object.setPrototypeOf(this, InternalServerException.prototype);
147+
this.retryAfterSeconds = opts.retryAfterSeconds;
148+
}
110149
}
111150

112151
/**
113152
* <p>The specified resource could not be found.</p>
114153
*/
115-
export interface ResourceNotFoundException extends __SmithyException, $MetadataBearer {
116-
name: "ResourceNotFoundException";
117-
$fault: "client";
118-
message: string | undefined;
154+
export class ResourceNotFoundException extends __BaseException {
155+
readonly name: "ResourceNotFoundException" = "ResourceNotFoundException";
156+
readonly $fault: "client" = "client";
119157
/**
120158
* <p>The ID of the resource.</p>
121159
*/
@@ -125,15 +163,28 @@ export interface ResourceNotFoundException extends __SmithyException, $MetadataB
125163
* <p>The type of the resource.</p>
126164
*/
127165
resourceType: string | undefined;
166+
167+
/**
168+
* @internal
169+
*/
170+
constructor(opts: __ExceptionOptionType<ResourceNotFoundException, __BaseException>) {
171+
super({
172+
name: "ResourceNotFoundException",
173+
$fault: "client",
174+
...opts,
175+
});
176+
Object.setPrototypeOf(this, ResourceNotFoundException.prototype);
177+
this.resourceId = opts.resourceId;
178+
this.resourceType = opts.resourceType;
179+
}
128180
}
129181

130182
/**
131183
* <p>Service quote met error.</p>
132184
*/
133-
export interface ServiceQuotaExceededException extends __SmithyException, $MetadataBearer {
134-
name: "ServiceQuotaExceededException";
135-
$fault: "client";
136-
message: string | undefined;
185+
export class ServiceQuotaExceededException extends __BaseException {
186+
readonly name: "ServiceQuotaExceededException" = "ServiceQuotaExceededException";
187+
readonly $fault: "client" = "client";
137188
/**
138189
* <p>The resource ID.</p>
139190
*/
@@ -143,22 +194,48 @@ export interface ServiceQuotaExceededException extends __SmithyException, $Metad
143194
* <p>The resource type.</p>
144195
*/
145196
resourceType: string | undefined;
197+
198+
/**
199+
* @internal
200+
*/
201+
constructor(opts: __ExceptionOptionType<ServiceQuotaExceededException, __BaseException>) {
202+
super({
203+
name: "ServiceQuotaExceededException",
204+
$fault: "client",
205+
...opts,
206+
});
207+
Object.setPrototypeOf(this, ServiceQuotaExceededException.prototype);
208+
this.resourceId = opts.resourceId;
209+
this.resourceType = opts.resourceType;
210+
}
146211
}
147212

148213
/**
149214
* <p>Throttling limit exceeded error.</p>
150215
*/
151-
export interface ThrottlingException extends __SmithyException, $MetadataBearer {
152-
name: "ThrottlingException";
153-
$fault: "client";
154-
$retryable: {
155-
throttling: true;
216+
export class ThrottlingException extends __BaseException {
217+
readonly name: "ThrottlingException" = "ThrottlingException";
218+
readonly $fault: "client" = "client";
219+
$retryable = {
220+
throttling: true,
156221
};
157-
message: string | undefined;
158222
/**
159223
* <p>The seconds to wait to retry.</p>
160224
*/
161225
retryAfterSeconds?: number;
226+
227+
/**
228+
* @internal
229+
*/
230+
constructor(opts: __ExceptionOptionType<ThrottlingException, __BaseException>) {
231+
super({
232+
name: "ThrottlingException",
233+
$fault: "client",
234+
...opts,
235+
});
236+
Object.setPrototypeOf(this, ThrottlingException.prototype);
237+
this.retryAfterSeconds = opts.retryAfterSeconds;
238+
}
162239
}
163240

164241
/**
@@ -195,10 +272,9 @@ export enum ValidationExceptionReason {
195272
/**
196273
* <p>Validation exception error.</p>
197274
*/
198-
export interface ValidationException extends __SmithyException, $MetadataBearer {
199-
name: "ValidationException";
200-
$fault: "client";
201-
message: string | undefined;
275+
export class ValidationException extends __BaseException {
276+
readonly name: "ValidationException" = "ValidationException";
277+
readonly $fault: "client" = "client";
202278
/**
203279
* <p>The reason for the exception.</p>
204280
*/
@@ -208,6 +284,20 @@ export interface ValidationException extends __SmithyException, $MetadataBearer
208284
* <p>A list of fields that didn't validate.</p>
209285
*/
210286
fieldList?: ValidationExceptionField[];
287+
288+
/**
289+
* @internal
290+
*/
291+
constructor(opts: __ExceptionOptionType<ValidationException, __BaseException>) {
292+
super({
293+
name: "ValidationException",
294+
$fault: "client",
295+
...opts,
296+
});
297+
Object.setPrototypeOf(this, ValidationException.prototype);
298+
this.reason = opts.reason;
299+
this.fieldList = opts.fieldList;
300+
}
211301
}
212302

213303
/**

0 commit comments

Comments
 (0)