Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions packages/binding-http/src/http-client-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,6 @@ export default class HttpClient implements ProtocolClient {

const result = await this.doFetch(request);

this.checkFetchResponse(result);

debug(`HttpClient received headers: ${JSON.stringify(result.headers.raw())}`);
debug(`HttpClient received Content-Type: ${result.headers.get("content-type")}`);

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

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

this.checkFetchResponse(result);

debug(`HttpClient received headers: ${JSON.stringify(result.headers.raw())}`);
}

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

this.checkFetchResponse(result);

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

if (HttpClient.isOAuthTokenExpired(result, this.credential)) {
this.credential = await (this.credential as OAuthCredential).refreshToken();
return await this._fetch(await this.credential.sign(request));
const resultAuth = await this._fetch(await this.credential.sign(request));
this.checkFetchResponse(resultAuth);
return resultAuth;
}

this.checkFetchResponse(result);

return result;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/wot-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export default class WoTImpl {
return value;
}

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

/** @inheritDoc */
Expand Down
Loading