Skip to content

Commit

Permalink
Fix error thrown with utf8 decoding
Browse files Browse the repository at this point in the history
  • Loading branch information
D4nte committed Mar 1, 2022
1 parent 75d420b commit 9d5df80
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 1 addition & 5 deletions examples/web-chat/src/Message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@ export class Message {
return new Message(chatMsg, wakuMsg.timestamp);
}
} catch (e) {
console.error(
"Failed to decode chat message",
wakuMsg.payloadAsUtf8,
e
);
console.error("Failed to decode chat message", e);
}
}
return;
Expand Down
6 changes: 5 additions & 1 deletion src/lib/waku_message/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,11 @@ export class WakuMessage {
return "";
}

return bytesToUtf8(this.proto.payload);
try {
return bytesToUtf8(this.proto.payload);
} catch (e) {
return "";
}
}

get payload(): Uint8Array | undefined {
Expand Down

0 comments on commit 9d5df80

Please sign in to comment.