make websocket errors more verbose

This commit is contained in:
Toshit Chawda 2024-09-06 22:24:56 -07:00
parent 0768cb9502
commit d6c095fe7b
No known key found for this signature in database
GPG key ID: 91480ED99E2B3D9D
2 changed files with 37 additions and 29 deletions

View file

@ -71,15 +71,15 @@ pub enum EpoxyError {
#[error("HTTP ToStr: {0:?} ({0})")]
ToStr(#[from] http::header::ToStrError),
#[cfg(feature = "full")]
#[error("Fastwebsockets: {0:?} ({0})")]
FastWebSockets(#[from] fastwebsockets::WebSocketError),
#[cfg(feature = "full")]
#[error("Pemfile: {0:?} ({0})")]
Pemfile(std::io::Error),
#[cfg(feature = "full")]
#[error("Webpki: {0:?} ({0})")]
Webpki(#[from] webpki::Error),
#[error("Wisp WebSocket failed to connect")]
WebSocketConnectFailed,
#[error("Custom wisp transport: {0}")]
WispTransport(String),
#[error("Invalid Wisp transport")]
@ -89,6 +89,22 @@ pub enum EpoxyError {
#[error("Wisp transport already closed")]
WispTransportClosed,
#[cfg(feature = "full")]
#[error("Fastwebsockets: {0:?} ({0})")]
FastWebSockets(#[from] fastwebsockets::WebSocketError),
#[cfg(feature = "full")]
#[error("Invalid websocket response status code: {0} != {1}")]
WsInvalidStatusCode(u16, u16),
#[cfg(feature = "full")]
#[error("Invalid websocket upgrade header: {0:?} != \"websocket\"")]
WsInvalidUpgradeHeader(String),
#[cfg(feature = "full")]
#[error("Invalid websocket connection header: {0:?} != \"Upgrade\"")]
WsInvalidConnectionHeader(String),
#[cfg(feature = "full")]
#[error("Invalid websocket payload, only String/ArrayBuffer accepted")]
WsInvalidPayload,
#[error("Invalid URL scheme")]
InvalidUrlScheme,
#[error("No URL host found")]
@ -99,22 +115,8 @@ pub enum EpoxyError {
InvalidRequestBody,
#[error("Invalid request")]
InvalidRequest,
#[error("Invalid websocket response status code")]
WsInvalidStatusCode,
#[error("Invalid websocket upgrade header")]
WsInvalidUpgradeHeader,
#[error("Invalid websocket connection header")]
WsInvalidConnectionHeader,
#[error("Invalid websocket payload")]
WsInvalidPayload,
#[error("Invalid payload")]
InvalidPayload,
#[error("Invalid certificate store")]
InvalidCertStore,
#[error("WebSocket failed to connect")]
WebSocketConnectFailed,
#[error("Failed to construct response headers object")]
ResponseHeadersFromEntriesFailed,
#[error("Failed to construct response object")]
@ -185,7 +187,6 @@ enum EpoxyCompression {
Gzip,
}
// ugly hack. switch to serde-wasm-bindgen or a knockoff
cfg_if! {
if #[cfg(feature = "full")] {