Skip to content

Commit

Permalink
feat(clients): throw exceptions as ServiceException class
Browse files Browse the repository at this point in the history
  • Loading branch information
AllanZhengYP committed Feb 19, 2022
1 parent 5c49c21 commit 511d61c
Show file tree
Hide file tree
Showing 1,234 changed files with 187,165 additions and 448,955 deletions.
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

0 comments on commit 511d61c

Please sign in to comment.