Skip to content

Commit

Permalink
redlink-gmbh/smarti#225: Improve error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Peyman Aparviz committed May 15, 2018
1 parent aad4eba commit 406eca9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
4 changes: 2 additions & 2 deletions packages/assistify-ai/server/SmartiProxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class SmartiProxy {
SystemLogger.error('Could not complete', method, 'to', url, error.response);
SystemLogger.debug(error);

if (onError) {
if (error && onError) {
const recoveryResult = onError(error);
if (recoveryResult !== undefined) {
return recoveryResult;
Expand All @@ -60,7 +60,7 @@ export class SmartiProxy {

SystemLogger.error('Could not complete', method, 'to', url, error.response);
SystemLogger.debug(error);
return false;
return {error};
}
}
}
18 changes: 6 additions & 12 deletions packages/assistify-ai/server/methods/SmartiWidgetBackend.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,9 @@ Meteor.methods({
}
}
)(verbs.get, `legacy/rocket.chat?channel_id=${ channelId }`, null, (error) => {
if (error) {
// 404 is expected if no mapping exists
if (error.response && error.response.statusCode === 404) {
return null;
}
return {errorCode: error.code};
// 404 is expected if no mapping exists
if (error.response && error.response.statusCode === 404) {
return null;
}
});

Expand Down Expand Up @@ -88,12 +85,9 @@ Meteor.methods({
}
}
)(verbs.get, `conversation/${ conversationId }/analysis`, null, (error) => {
if (error) {
// 404 is expected if no mapping exists
if (error.response && error.response.statusCode === 404) {
return null;
}
return {errorCode: error.code};
// 404 is expected if no mapping exists
if (error.response && error.response.statusCode === 404) {
return null;
}
});
},
Expand Down

0 comments on commit 406eca9

Please sign in to comment.