File tree Expand file tree Collapse file tree 4 files changed +46
-2
lines changed Expand file tree Collapse file tree 4 files changed +46
-2
lines changed Original file line number Diff line number Diff line change
1
+ import { ResponseMetadata } from './response' ;
2
+ import { MetadataBearer } from './index' ;
3
+
4
+ /**
5
+ * Exceptions that responded from AWS service containing raw http response
6
+ * and parsed exception object
7
+ *
8
+ * @property {any } details - parsed exception object normalized according to
9
+ * its API model
10
+ */
11
+ export interface ServiceException < Details = any > extends Error , MetadataBearer {
12
+ details : Details ;
13
+ }
14
+
15
+ /**
16
+ * Service exceptions that can not be parsed by unmarshallers' error parser
17
+ */
18
+ export interface UnkownServiceException extends ServiceException < undefined > {
19
+ name : 'Error'
20
+ }
Original file line number Diff line number Diff line change @@ -67,6 +67,14 @@ export interface HttpResponse<StreamType = Uint8Array> extends
67
67
statusCode : number ;
68
68
}
69
69
70
+ /**
71
+ * Represents HTTP message whose body has been resolved to a string. This is
72
+ * used in parsing http message.
73
+ */
74
+ export interface ResolvedHttpResponse extends HttpResponse {
75
+ body : string
76
+ }
77
+
70
78
71
79
/**
72
80
* A class that stores httpOptions and can make requests by calling handle.
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ export * from './client';
3
3
export * from './command' ;
4
4
export * from './credentials' ;
5
5
export * from './crypto' ;
6
+ export * from './exception' ;
6
7
export * from './http' ;
7
8
export * from './logger' ;
8
9
export * from './marshaller' ;
Original file line number Diff line number Diff line change 1
- import { Member , OperationModel } from "./protocol" ;
2
- import { HttpResponse } from "./http" ;
1
+ import {
2
+ Member ,
3
+ OperationModel ,
4
+ } from "./protocol" ;
5
+ import {
6
+ HttpResponse ,
7
+ ResolvedHttpResponse ,
8
+ } from "./http" ;
3
9
import { MetadataBearer } from './response' ;
10
+ import { ServiceException } from './exception' ;
4
11
5
12
export interface BodyParser < SerializedType = string > {
6
13
/**
@@ -37,3 +44,11 @@ export interface ResponseParser<StreamType = Uint8Array> {
37
44
export interface StreamCollector < StreamType > {
38
45
( stream : StreamType ) : Promise < Uint8Array > ;
39
46
}
47
+
48
+ /**
49
+ * A function that parses the http response when http status code > 299,
50
+ * parse the error response according to response and throw the ServiceException
51
+ */
52
+ export interface ServiceExceptionParser {
53
+ ( operation : OperationModel , response : ResolvedHttpResponse , errorBodyParser : BodyParser ) : ServiceException
54
+ }
You can’t perform that action at this time.
0 commit comments