|
1 | 1 | import { HttpResponse, MetadataBearer, ResponseMetadata, RetryableTrait, SmithyException } from "@aws-sdk/types";
|
2 | 2 |
|
3 | 3 | export class ClientException extends Error {
|
4 |
| - /** |
5 |
| - * The shape ID name of the exception. |
6 |
| - */ |
7 |
| - readonly name: string; |
8 | 4 | /**
|
9 | 5 | * Whether the client or server are at fault.
|
10 | 6 | */
|
11 | 7 | readonly $fault: "client" | "server";
|
12 | 8 |
|
13 |
| - /** |
14 |
| - * The service that encountered the exception. |
15 |
| - */ |
16 |
| - readonly $service?: string; |
17 |
| - |
18 |
| - /** |
19 |
| - * Indicates that an error MAY be retried by the client. |
20 |
| - */ |
21 |
| - readonly $retryable?: RetryableTrait; |
22 |
| - |
23 |
| - readonly $frameworkError?: boolean; |
24 |
| - readonly statusCode?: number; |
25 |
| - |
26 |
| - constructor(options: { |
27 |
| - name: string; |
28 |
| - $fault: "client" | "server"; |
29 |
| - message?: string; |
30 |
| - $service?: string; |
31 |
| - $retryable?: RetryableTrait; |
32 |
| - $frameworkError?: boolean; |
33 |
| - statusCode?: number; |
34 |
| - }) { |
| 9 | + constructor(options: { name: string; $fault: "client" | "server"; message?: string }) { |
35 | 10 | super(options.message);
|
| 11 | + Object.setPrototypeOf(this, ClientException.prototype); |
36 | 12 | this.name = options.name;
|
37 | 13 | this.$fault = options.$fault;
|
38 |
| - this.$service = options.$service; |
39 |
| - this.$retryable = options.$retryable; |
40 |
| - this.$frameworkError = options.$frameworkError; |
41 |
| - this.statusCode = options.statusCode; |
42 |
| - Object.setPrototypeOf(this, ClientException.prototype); |
43 | 14 | }
|
44 | 15 | }
|
45 | 16 |
|
| 17 | +/** |
| 18 | + * The type of the exception class constructor parameter. The returned type contains the properties |
| 19 | + * in the `ExceptionType` but not in the `BaseExceptionType`. If the `BaseExceptionType` contains |
| 20 | + * `$metadata` property, it's also included in the returned type. |
| 21 | + */ |
| 22 | +export type ExceptionOptionType<ExceptionType extends Error, BaseExceptionType extends Error> = Omit< |
| 23 | + ExceptionType, |
| 24 | + Exclude<keyof BaseExceptionType, "$metadata"> |
| 25 | +>; |
| 26 | + |
46 | 27 | export interface ServiceExceptionOptions extends SmithyException, MetadataBearer {
|
47 | 28 | message?: string;
|
48 | 29 | }
|
|
0 commit comments