Skip to content

fix: correct catch ordering and migrate to spdlog#99

Open
siddimore wants to merge 2 commits intolivekit:mainfrom
siddimore:fix/bridge-error-handling-and-logging
Open

fix: correct catch ordering and migrate to spdlog#99
siddimore wants to merge 2 commits intolivekit:mainfrom
siddimore:fix/bridge-error-handling-and-logging

Conversation

@siddimore
Copy link
Copy Markdown
Contributor

  • RpcError catches now log code() and message() instead of just what(), preserving the structured error information (error code, message, data).

  • Replace all std::cerr usage across bridge/ with LK_LOG_ERROR and LK_LOG_WARN macros (spdlog), consistent with the rest of the SDK. Remove includes that are no longer needed.

  • Add missing #pragma once include guard to src/track_proto_converter.h, which had no include guard at all (every other header in the project has one).

…uard

- Fix exception catch ordering in 5 RPC methods in livekit_bridge.cpp:
  catch(std::exception) was listed before catch(livekit::RpcError),
  making the RpcError handler unreachable dead code. Since RpcError
  extends std::runtime_error (which extends std::exception), the
  most-derived type must be caught first. Reorder to:
  catch(RpcError) -> catch(std::exception), and remove the redundant
  catch(std::runtime_error) clause entirely.

- RpcError catches now log code() and message() instead of just what(),
  preserving the structured error information (error code, message, data).

- Replace all std::cerr usage across bridge/ with LK_LOG_ERROR and
  LK_LOG_WARN macros (spdlog), consistent with the rest of the SDK.
  Remove <iostream> includes that are no longer needed.

- Add missing #pragma once include guard to src/track_proto_converter.h,
  which had no include guard at all (every other header in the project
  has one).
@siddimore siddimore changed the title fix: correct catch ordering, migrate to spdlog, add missing include g… fix: correct catch ordering and migrate to spdlog Apr 16, 2026
@siddimore siddimore marked this pull request as ready for review April 16, 2026 05:40
spdlog::spdlog is linked PRIVATE to the livekit target, so its headers
do not propagate to livekit_bridge. Add an explicit PRIVATE link to
spdlog::spdlog and set SPDLOG_ACTIVE_LEVEL so the bridge can use
LK_LOG_* macros from lk_log.h.
@xianshijing-lk
Copy link
Copy Markdown
Collaborator

Hi @stephen-derosa and @alan-george-lk , could you please review this PR ?

Copy link
Copy Markdown
Contributor

@alan-george-lk alan-george-lk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes LGTM -- I will however hold off approving until @stephen-derosa takes a look. AFAIK the bridge is deprecated, so we may be minimizing changes to it. @siddimore are you actively using it?

return std::nullopt;
} catch (const livekit::RpcError &e) {
std::cerr << "[LiveKitBridge] RPC error: " << e.what() << "\n";
LK_LOG_ERROR("performRpc RPC error (code {}): {}", e.code(), e.message());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we preserve the [LiveKitBridge] prefix here?

[LiveKitBridge] performRpc ...

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

preferred for sure

Copy link
Copy Markdown
Contributor

@stephen-derosa stephen-derosa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@siddimore are you actively using the bridge? FYI the bridge has been deperecated since its functionality has been moved to the core cpp sdk. Are you able to migrate to the base sdk?

* limitations under the License.
*/

#pragma once
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for this!

@siddimore
Copy link
Copy Markdown
Contributor Author

siddimore commented Apr 17, 2026

Changes LGTM -- I will however hold off approving until @stephen-derosa takes a look. AFAIK the bridge is deprecated, so we may be minimizing changes to it. @siddimore are you actively using it?

@alan-george-lk not actively using just trying it out.

@stephen-derosa
Copy link
Copy Markdown
Contributor

Changes LGTM -- I will however hold off approving until @stephen-derosa takes a look. AFAIK the bridge is deprecated, so we may be minimizing changes to it. @siddimore are you actively using it?

@alan-george-lk not actively using just trying it out.

@siddimore id prefer that we dont touch the bridge, especially since this is sort of feature/maintenance work. We are really excited for your contributions though!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants