mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-27 11:51:08 +00:00
Proper error logging for websocket
This commit is contained in:
parent
4fbf55d79e
commit
ef6df1339f
3 changed files with 13 additions and 7 deletions
1
server/Cargo.lock
generated
vendored
1
server/Cargo.lock
generated
vendored
|
@ -1448,6 +1448,7 @@ dependencies = [
|
||||||
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"lettre 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"lettre 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"lettre_email 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"lettre_email 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"percent-encoding 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"percent-encoding 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"regex 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
"regex 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
|
1
server/Cargo.toml
vendored
1
server/Cargo.toml
vendored
|
@ -19,6 +19,7 @@ actix-web = "2.0.0"
|
||||||
actix-files = "0.2.1"
|
actix-files = "0.2.1"
|
||||||
actix-web-actors = "2.0.0"
|
actix-web-actors = "2.0.0"
|
||||||
actix-rt = "1.0.0"
|
actix-rt = "1.0.0"
|
||||||
|
log = "0.4.0"
|
||||||
env_logger = "0.7.1"
|
env_logger = "0.7.1"
|
||||||
rand = "0.7.3"
|
rand = "0.7.3"
|
||||||
strum = "0.17.1"
|
strum = "0.17.1"
|
||||||
|
|
|
@ -6,6 +6,7 @@ use actix::prelude::*;
|
||||||
use diesel::r2d2::{ConnectionManager, Pool, PooledConnection};
|
use diesel::r2d2::{ConnectionManager, Pool, PooledConnection};
|
||||||
use diesel::PgConnection;
|
use diesel::PgConnection;
|
||||||
use failure::Error;
|
use failure::Error;
|
||||||
|
use log::warn;
|
||||||
use rand::{rngs::ThreadRng, Rng};
|
use rand::{rngs::ThreadRng, Rng};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
|
@ -448,13 +449,16 @@ impl Handler<StandardMessage> for ChatServer {
|
||||||
type Result = MessageResult<StandardMessage>;
|
type Result = MessageResult<StandardMessage>;
|
||||||
|
|
||||||
fn handle(&mut self, msg: StandardMessage, _: &mut Context<Self>) -> Self::Result {
|
fn handle(&mut self, msg: StandardMessage, _: &mut Context<Self>) -> Self::Result {
|
||||||
let msg_out = match parse_json_message(self, msg) {
|
match parse_json_message(self, msg) {
|
||||||
Ok(m) => m,
|
Ok(m) => {
|
||||||
Err(e) => e.to_string(),
|
println!("Message Sent: {}", m);
|
||||||
};
|
MessageResult(m)
|
||||||
|
}
|
||||||
println!("Message Sent: {}", msg_out);
|
Err(e) => {
|
||||||
MessageResult(msg_out)
|
warn!("Error during message handling {}", e);
|
||||||
|
MessageResult(e.to_string())
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue