Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(clients): generate service exceptions as classes #3267

Merged
merged 2 commits into from Feb 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions clients/client-accessanalyzer/src/index.ts
Expand Up @@ -3,3 +3,4 @@ export * from "./AccessAnalyzerClient";
export * from "./commands";
export * from "./models";
export * from "./pagination";
export { AccessAnalyzerServiceException } from "./models/AccessAnalyzerServiceException";
@@ -0,0 +1,17 @@
import {
ServiceException as __ServiceException,
ServiceExceptionOptions as __ServiceExceptionOptions,
} from "@aws-sdk/smithy-client";

/**
* Base exception class for all service exceptions from AccessAnalyzer service.
*/
export class AccessAnalyzerServiceException extends __ServiceException {
/**
* @internal
*/
constructor(options: __ServiceExceptionOptions) {
super(options);
Object.setPrototypeOf(this, AccessAnalyzerServiceException.prototype);
}
}
153 changes: 121 additions & 32 deletions clients/client-accessanalyzer/src/models/models_0.ts
@@ -1,21 +1,33 @@
import { MetadataBearer as $MetadataBearer, SmithyException as __SmithyException } from "@aws-sdk/types";
import { ExceptionOptionType as __ExceptionOptionType } from "@aws-sdk/smithy-client";
import { MetadataBearer as $MetadataBearer } from "@aws-sdk/types";

import { AccessAnalyzerServiceException as __BaseException } from "./AccessAnalyzerServiceException";

/**
* <p>You do not have sufficient access to perform this action.</p>
*/
export interface AccessDeniedException extends __SmithyException, $MetadataBearer {
name: "AccessDeniedException";
$fault: "client";
message: string | undefined;
export class AccessDeniedException extends __BaseException {
readonly name: "AccessDeniedException" = "AccessDeniedException";
readonly $fault: "client" = "client";
/**
* @internal
*/
constructor(opts: __ExceptionOptionType<AccessDeniedException, __BaseException>) {
super({
name: "AccessDeniedException",
$fault: "client",
...opts,
});
Object.setPrototypeOf(this, AccessDeniedException.prototype);
}
}

/**
* <p>A conflict exception error.</p>
*/
export interface ConflictException extends __SmithyException, $MetadataBearer {
name: "ConflictException";
$fault: "client";
message: string | undefined;
export class ConflictException extends __BaseException {
readonly name: "ConflictException" = "ConflictException";
readonly $fault: "client" = "client";
/**
* <p>The ID of the resource.</p>
*/
Expand All @@ -25,6 +37,20 @@ export interface ConflictException extends __SmithyException, $MetadataBearer {
* <p>The resource type.</p>
*/
resourceType: string | undefined;

/**
* @internal
*/
constructor(opts: __ExceptionOptionType<ConflictException, __BaseException>) {
super({
name: "ConflictException",
$fault: "client",
...opts,
});
Object.setPrototypeOf(this, ConflictException.prototype);
this.resourceId = opts.resourceId;
this.resourceType = opts.resourceType;
}
}

/**
Expand Down Expand Up @@ -98,24 +124,35 @@ export namespace CreateArchiveRuleRequest {
/**
* <p>Internal server error.</p>
*/
export interface InternalServerException extends __SmithyException, $MetadataBearer {
name: "InternalServerException";
$fault: "server";
$retryable: {};
message: string | undefined;
export class InternalServerException extends __BaseException {
readonly name: "InternalServerException" = "InternalServerException";
readonly $fault: "server" = "server";
$retryable = {};
/**
* <p>The seconds to wait to retry.</p>
*/
retryAfterSeconds?: number;

/**
* @internal
*/
constructor(opts: __ExceptionOptionType<InternalServerException, __BaseException>) {
super({
name: "InternalServerException",
$fault: "server",
...opts,
});
Object.setPrototypeOf(this, InternalServerException.prototype);
this.retryAfterSeconds = opts.retryAfterSeconds;
}
}

/**
* <p>The specified resource could not be found.</p>
*/
export interface ResourceNotFoundException extends __SmithyException, $MetadataBearer {
name: "ResourceNotFoundException";
$fault: "client";
message: string | undefined;
export class ResourceNotFoundException extends __BaseException {
readonly name: "ResourceNotFoundException" = "ResourceNotFoundException";
readonly $fault: "client" = "client";
/**
* <p>The ID of the resource.</p>
*/
Expand All @@ -125,15 +162,28 @@ export interface ResourceNotFoundException extends __SmithyException, $MetadataB
* <p>The type of the resource.</p>
*/
resourceType: string | undefined;

/**
* @internal
*/
constructor(opts: __ExceptionOptionType<ResourceNotFoundException, __BaseException>) {
super({
name: "ResourceNotFoundException",
$fault: "client",
...opts,
});
Object.setPrototypeOf(this, ResourceNotFoundException.prototype);
this.resourceId = opts.resourceId;
this.resourceType = opts.resourceType;
}
}

/**
* <p>Service quote met error.</p>
*/
export interface ServiceQuotaExceededException extends __SmithyException, $MetadataBearer {
name: "ServiceQuotaExceededException";
$fault: "client";
message: string | undefined;
export class ServiceQuotaExceededException extends __BaseException {
readonly name: "ServiceQuotaExceededException" = "ServiceQuotaExceededException";
readonly $fault: "client" = "client";
/**
* <p>The resource ID.</p>
*/
Expand All @@ -143,22 +193,48 @@ export interface ServiceQuotaExceededException extends __SmithyException, $Metad
* <p>The resource type.</p>
*/
resourceType: string | undefined;

/**
* @internal
*/
constructor(opts: __ExceptionOptionType<ServiceQuotaExceededException, __BaseException>) {
super({
name: "ServiceQuotaExceededException",
$fault: "client",
...opts,
});
Object.setPrototypeOf(this, ServiceQuotaExceededException.prototype);
this.resourceId = opts.resourceId;
this.resourceType = opts.resourceType;
}
}

/**
* <p>Throttling limit exceeded error.</p>
*/
export interface ThrottlingException extends __SmithyException, $MetadataBearer {
name: "ThrottlingException";
$fault: "client";
$retryable: {
throttling: true;
export class ThrottlingException extends __BaseException {
readonly name: "ThrottlingException" = "ThrottlingException";
readonly $fault: "client" = "client";
$retryable = {
throttling: true,
};
message: string | undefined;
/**
* <p>The seconds to wait to retry.</p>
*/
retryAfterSeconds?: number;

/**
* @internal
*/
constructor(opts: __ExceptionOptionType<ThrottlingException, __BaseException>) {
super({
name: "ThrottlingException",
$fault: "client",
...opts,
});
Object.setPrototypeOf(this, ThrottlingException.prototype);
this.retryAfterSeconds = opts.retryAfterSeconds;
}
}

/**
Expand Down Expand Up @@ -195,10 +271,9 @@ export enum ValidationExceptionReason {
/**
* <p>Validation exception error.</p>
*/
export interface ValidationException extends __SmithyException, $MetadataBearer {
name: "ValidationException";
$fault: "client";
message: string | undefined;
export class ValidationException extends __BaseException {
readonly name: "ValidationException" = "ValidationException";
readonly $fault: "client" = "client";
/**
* <p>The reason for the exception.</p>
*/
Expand All @@ -208,6 +283,20 @@ export interface ValidationException extends __SmithyException, $MetadataBearer
* <p>A list of fields that didn't validate.</p>
*/
fieldList?: ValidationExceptionField[];

/**
* @internal
*/
constructor(opts: __ExceptionOptionType<ValidationException, __BaseException>) {
super({
name: "ValidationException",
$fault: "client",
...opts,
});
Object.setPrototypeOf(this, ValidationException.prototype);
this.reason = opts.reason;
this.fieldList = opts.fieldList;
}
}

/**
Expand Down