Skip to content

Commit 7c4a984

Browse files
Merge pull request #4 from stevenpkg/chor__session-errors
chor(session error) Added session time out error to show in chat area
2 parents 96e33c4 + 737376e commit 7c4a984

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

src/components/App.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -258,16 +258,18 @@ class App extends React.Component {
258258
this.updateMessageStatus(IN_PROGRESS);
259259

260260
fetchMessage(text, context, (err, data) => {
261-
if (err) {
261+
// data.code is set for an error response
262+
if (err || data.code !== undefined) {
262263
this.updateMessageStatus(FAILED);
263264

264265
this.updateChatList({
265266
type: 'bot',
266-
content: 'Could not connect to Watson Assistant',
267+
content: 'I\'m having trouble connecting to the server, please refresh the page.',
267268
});
268269

269-
console.log(err);
270-
throw new Error(err);
270+
const errorMsg = (err) || data;
271+
272+
throw new Error(errorMsg);
271273
}
272274
// update message status
273275
this.updateMessageStatus(COMPLETED);

0 commit comments

Comments
 (0)