Skip to content

Commit

Permalink
Provide more context to ConnectionError when connecting to a room (#575)
Browse files Browse the repository at this point in the history
* Provide more context to ConnectionError when connecting to a room

* Fix prettier issues

* Create mighty-boats-wonder.md

---------

Co-authored-by: lukasIO <lukas.seiler@neesh.de>
  • Loading branch information
HermanBilous and lukasIO committed Feb 7, 2023
1 parent e3e7c78 commit b8fd583
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/mighty-boats-wonder.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"livekit-client": patch
---

Provide more context to ConnectionError when connecting to a room
12 changes: 8 additions & 4 deletions src/room/Room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -355,12 +355,16 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
} catch (err) {
this.recreateEngine();
this.handleDisconnect(this.options.stopLocalTrackOnUnpublish);
let errorMessage = '';
const resultingError = new ConnectionError(`could not establish signal connection`);
if (err instanceof Error) {
errorMessage = err.message;
log.debug(`error trying to establish signal connection`, { error: err });
resultingError.message = `${resultingError.message}: ${err.message}`;
}
reject(new ConnectionError(`could not establish signal connection: ${errorMessage}`));
if (err instanceof ConnectionError) {
resultingError.reason = err.reason;
resultingError.status = err.status;
}
log.debug(`error trying to establish signal connection`, { error: err });
reject(resultingError);
return;
}

Expand Down

0 comments on commit b8fd583

Please sign in to comment.