pub struct WSError { /* private fields */ }Expand description
WebSocket error for both internal handling and client responses.
Serializes as {"param": "...", "code": N, "msg": "..."} for JSON responses.
Implementations§
Source§impl WSError
impl WSError
Sourcepub fn with_message(code: ErrorCode, message: impl Into<String>) -> Self
pub fn with_message(code: ErrorCode, message: impl Into<String>) -> Self
Create error with custom message
Sourcepub fn with_param(
code: ErrorCode,
param: impl Into<String>,
message: impl Into<String>,
) -> Self
pub fn with_param( code: ErrorCode, param: impl Into<String>, message: impl Into<String>, ) -> Self
Create error with param context (for atomic batch failures)
Sourcepub fn error_code(&self) -> ErrorCode
pub fn error_code(&self) -> ErrorCode
Get the error code
pub fn invalid_request(msg: impl Into<String>) -> Self
pub fn invalid_subscription(msg: impl Into<String>) -> Self
pub fn invalid_subscription_with_param( param: impl Into<String>, msg: impl Into<String>, ) -> Self
pub fn symbol_not_found(symbol: &str) -> Self
pub fn subscription_exists(param: impl Into<String>) -> Self
pub fn mandatory_param_missing(msg: impl Into<String>) -> Self
pub fn server_busy(msg: impl Into<String>) -> Self
Trait Implementations§
Source§impl<'de> Deserialize<'de> for WSError
impl<'de> Deserialize<'de> for WSError
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Error for WSError
impl Error for WSError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0:
use the Display impl or to_string()
Auto Trait Implementations§
impl Freeze for WSError
impl RefUnwindSafe for WSError
impl Send for WSError
impl Sync for WSError
impl Unpin for WSError
impl UnsafeUnpin for WSError
impl UnwindSafe for WSError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more