Skip to content

Commit 81a5de0

Browse files
authored
Implement Display and Error for RpcError (#719)
1 parent fed9cc6 commit 81a5de0

File tree

1 file changed

+8
-1
lines changed
  • livekit/src/room/participant

1 file changed

+8
-1
lines changed

livekit/src/room/participant/rpc.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use crate::room::participant::ParticipantIdentity;
66
use livekit_protocol::RpcError as RpcError_Proto;
7-
use std::time::Duration;
7+
use std::{error::Error, fmt::Display, time::Duration};
88

99
/// Parameters for performing an RPC call
1010
#[derive(Debug, Clone)]
@@ -84,6 +84,13 @@ impl RpcError {
8484
}
8585
}
8686

87+
impl Display for RpcError {
88+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
89+
write!(f, "RPC Error: {} ({})", self.message, self.code)
90+
}
91+
}
92+
impl Error for RpcError {}
93+
8794
#[derive(Debug, Clone, Copy)]
8895
pub enum RpcErrorCode {
8996
ApplicationError = 1500,

0 commit comments

Comments
 (0)