Skip to content

Commit

Permalink
Improved error logging when opening a bot via URL in debug mode (#1949)
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyanziano authored Nov 5, 2019
1 parent 9c4a6ce commit a070872
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## Fixed
- [client] Added an empty state for the recent bots submenu in the app menu for Windows in PR [1945](https://github.com/microsoft/BotFramework-Emulator/pull/1945)
- [client] Fixed a bug that was showing the custom user ID validation message when disabled in PR [1946](https://github.com/microsoft/BotFramework-Emulator/pull/1946)
- [client] Improved error logging when opening a bot via URL in debug mode in PR [1949](https://github.com/microsoft/BotFramework-Emulator/pull/1949)

## v4.6.0 - 2019 - 10 - 31
## Added
Expand Down
8 changes: 6 additions & 2 deletions packages/app/client/src/state/sagas/botSagas.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -384,11 +384,15 @@ describe('The botSagas', () => {
gen.next({ id: 'someConversationId' });
// POSTing to the conversation should return a 400
const errorNotification = beginAdd(
newNotification('An error occurred while POSTing "/INSPECT open" command to conversation someConversationId')
newNotification(
'An error occurred while POSTing "/INSPECT open" command to conversation someConversationId: Bad request: Something went wrong :('
)
);
(errorNotification as any).payload.notification.timestamp = jasmine.any(Number);
(errorNotification as any).payload.notification.id = jasmine.any(String);
expect(gen.next({ statusCode: 400 }).value).toEqual(put(errorNotification));
expect(
gen.next({ response: { status: 'Bad request', message: 'Something went wrong :(' }, statusCode: 400 }).value
).toEqual(put(errorNotification));
});

it('should spawn a notification if parsing the conversation id from the response fails', () => {
Expand Down
11 changes: 9 additions & 2 deletions packages/app/client/src/state/sagas/botSagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,14 +170,21 @@ export class BotSagas {
type: 'message',
text: '/INSPECT open',
};
const postActivityResponse: ResourceResponse & { statusCode: number } = yield call(
const postActivityResponse: ResourceResponse & {
statusCode: number;
response?: { message: string; status: number | string };
} = yield call(
[BotSagas.commandService, BotSagas.commandService.remoteCall],
SharedConstants.Commands.Emulator.PostActivityToConversation,
conversationId,
activity
);
if (postActivityResponse.statusCode > 399) {
error = `An error occurred while POSTing "/INSPECT open" command to conversation ${conversationId}`;
const { message = 'Message unavailable.', status = 'Status unavailable' } =
postActivityResponse.response || {};
error =
`An error occurred while POSTing "/INSPECT open" command to conversation ${conversationId}: ` +
`${status}: ${message}`;
}
} else {
error = 'An error occurred while trying to grab conversation ID from the new conversation.';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
display: block;
text-align: right;
min-width: 0;
margin-right: 20px;
margin: 0 20px;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
Expand Down

0 comments on commit a070872

Please sign in to comment.