Skip to content

Commit 380ef25

Browse files
author
evgeny.ivanov
committed
SDK regenerated by CI server [ci skip]
1 parent 03a0b5a commit 380ef25

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/internal/requestHelper.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,11 @@ async function invokeApiMethodInternal(requestOptions: request.OptionsWithUri, c
125125

126126
const auth = confguration.authentication;
127127
if (!notApplyAuthToRequest) {
128-
await auth.applyToRequest(requestOptions, confguration);
128+
try {
129+
await auth.applyToRequest(requestOptions, confguration);
130+
} catch (error) {
131+
throw new Error("Authorization failed")
132+
}
129133
}
130134

131135
return new Promise<request.RequestResponse>((resolve, reject) => {
@@ -136,8 +140,12 @@ async function invokeApiMethodInternal(requestOptions: request.OptionsWithUri, c
136140
if (response.statusCode >= 200 && response.statusCode <= 299) {
137141
resolve(response);
138142
} else if (response.statusCode === 401 && !notApplyAuthToRequest) {
139-
await auth.handle401response(confguration);
140-
reject(new NeedRepeatException());
143+
try {
144+
await auth.handle401response(confguration);
145+
reject(new NeedRepeatException());
146+
} catch (error) {
147+
reject({ message: "Error while getting token: " + error });
148+
}
141149
} else {
142150
try {
143151
let bodyContent = response.body;

0 commit comments

Comments
 (0)