Skip to content
Permalink
Browse files

[DDW-677] Fix error handling, Adds more logging

  • Loading branch information...
nikolaglumac committed Jun 12, 2019
1 parent 70de07a commit 3f87c698f617a76dd50ec6c75265d950572bce97
Showing with 10 additions and 4 deletions.
  1. +9 −3 source/renderer/app/api/utils/externalRequest.js
  2. +1 −1 source/renderer/app/stores/NodeUpdateStore.js
@@ -24,16 +24,22 @@ export const externalRequest = (httpOptions: HttpOptions): Promise<any> => (
const options = omit(httpOptions, 'protocol');
const requestMethod = global[protocol].request;
const request = requestMethod(options);

console.debug('[externalRequest::start]', options, request);
request.on('response', response => {
let body = '';
response.on('data', chunk => {
body += chunk;
});
response.on('error', error => reject(error));
response.on('end', () => {
const parsedBody = JSON.parse(body);
return resolve(parsedBody);
try {
console.debug('[externalRequest::end]', body);
const parsedBody = JSON.parse(body);
resolve(parsedBody);
} catch (error) {
// Handle internal server errors (e.g. HTTP 500 - 'Something went wrong')
reject(new Error(error));
}
});
});
request.on('error', error => reject(error));
@@ -111,7 +111,7 @@ export default class NodeUpdateStore extends Store {
return (
this.getLatestAppVersionRequest.wasExecuted &&
(this.getLatestAppVersionRequest.result !== null ||
this.getLatestAppVersionRequest.error)
this.getLatestAppVersionRequest.error !== null)
);
}

0 comments on commit 3f87c69

Please sign in to comment.
You can’t perform that action at this time.