Subscriptions working
This commit is contained in:
22
src/error.rs
22
src/error.rs
@ -1,4 +1,4 @@
|
||||
use crate::usimp::{InputEnvelope, OutputEnvelope};
|
||||
use crate::usimp::{InputEnvelope, OutputEnvelope, Event};
|
||||
|
||||
use serde_json::{Value, Map};
|
||||
use bb8_postgres::tokio_postgres;
|
||||
@ -25,6 +25,10 @@ pub enum ErrorKind {
|
||||
UsimpError,
|
||||
WebSocketError,
|
||||
DatabaseError,
|
||||
InvalidSessionError,
|
||||
AuthenticationError,
|
||||
SubscriptionError,
|
||||
InternalError,
|
||||
}
|
||||
|
||||
impl InputEnvelope {
|
||||
@ -64,7 +68,10 @@ impl Error {
|
||||
ErrorKind::NotImplemented => "NOT_IMPLEMENTED",
|
||||
ErrorKind::UsimpError => "USIMP_ERROR",
|
||||
ErrorKind::WebSocketError => "WEBSOCKET_ERROR",
|
||||
ErrorKind::DatabaseError => "BACKEND_ERROR",
|
||||
ErrorKind::DatabaseError | ErrorKind::InternalError => "SERVER_ERROR",
|
||||
ErrorKind::InvalidSessionError => "INVALID_SESSION_ERROR",
|
||||
ErrorKind::AuthenticationError => "AUTHENTICATION_ERROR",
|
||||
ErrorKind::SubscriptionError => "SUBSCRIPTION_ERROR",
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -149,3 +156,14 @@ impl From<bb8_postgres::bb8::RunError<tokio_postgres::Error>> for Error {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<tokio::sync::mpsc::error::SendError<Event>> for Error {
|
||||
fn from(error: tokio::sync::mpsc::error::SendError<Event>) -> Self {
|
||||
Error {
|
||||
kind: ErrorKind::InternalError,
|
||||
class: ErrorClass::ServerError,
|
||||
msg: None,
|
||||
desc: Some(error.to_string()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user