Skip to content

Commit

Permalink
feat: special-case error events to serialize message field
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielgrant committed Aug 16, 2017
1 parent 3006e76 commit 78b8b4b
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/server/call.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,15 @@ export class Call {

private callEventHandler(eventId: string, isBin: boolean = false) {
return (data: any) => {
if (eventId === 'error') {
// An error's message is not enumerable, so doesn't get included
// by JSON.stringify(). Copy error info to a new, serializable object
let enumerableError: any = {};
Object.getOwnPropertyNames(data).forEach(key => {
enumerableError[key] = data[key];
});
data = enumerableError;
}
let callEvent: IGBCallEvent = {
service_id: this.clientServiceId,
call_id: this.clientId,
Expand Down

0 comments on commit 78b8b4b

Please sign in to comment.