Skip to content

Commit 8cd451b

Browse files
authored
Merge pull request eclipse-thingweb#1404 from danielpeintner/issue-1403
Improve TD validation error in requestThingDescription
2 parents 699e6b6 + ec8fa05 commit 8cd451b

2 files changed

Lines changed: 6 additions & 8 deletions

File tree

packages/binding-http/src/http-client-impl.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,6 @@ export default class HttpClient implements ProtocolClient {
128128

129129
const result = await this.doFetch(request);
130130

131-
this.checkFetchResponse(result);
132-
133131
debug(`HttpClient received headers: ${JSON.stringify(result.headers.raw())}`);
134132
debug(`HttpClient received Content-Type: ${result.headers.get("content-type")}`);
135133

@@ -154,8 +152,6 @@ export default class HttpClient implements ProtocolClient {
154152

155153
debug(`HttpClient received ${result.status} from ${result.url}`);
156154

157-
this.checkFetchResponse(result);
158-
159155
debug(`HttpClient received headers: ${JSON.stringify(result.headers.raw())}`);
160156
}
161157

@@ -218,8 +214,6 @@ export default class HttpClient implements ProtocolClient {
218214
debug(`HttpClient received ${result.status} from ${request.url}`);
219215
debug(`HttpClient received Content-Type: ${result.headers.get("content-type")}`);
220216

221-
this.checkFetchResponse(result);
222-
223217
// in browsers node-fetch uses the native fetch, which returns a ReadableStream
224218
// not complaint with node. Therefore we have to force the conversion here.
225219
const body = ProtocolHelpers.toNodeStream(result.body as Readable);
@@ -432,9 +426,13 @@ export default class HttpClient implements ProtocolClient {
432426

433427
if (HttpClient.isOAuthTokenExpired(result, this.credential)) {
434428
this.credential = await (this.credential as OAuthCredential).refreshToken();
435-
return await this._fetch(await this.credential.sign(request));
429+
const resultAuth = await this._fetch(await this.credential.sign(request));
430+
this.checkFetchResponse(resultAuth);
431+
return resultAuth;
436432
}
437433

434+
this.checkFetchResponse(result);
435+
438436
return result;
439437
}
440438

packages/core/src/wot-impl.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export default class WoTImpl {
100100
return value;
101101
}
102102

103-
throw getLastValidationErrors();
103+
throw new Error("TD validation error: " + getLastValidationErrors().message);
104104
}
105105

106106
/** @inheritDoc */

0 commit comments

Comments
 (0)