Skip to content
Snippets Groups Projects
Commit e06f5c8f authored by David Huss's avatar David Huss :speech_balloon:
Browse files

Fix error with eventhandler

parent 5165d381
Branches
No related tags found
No related merge requests found
......@@ -1376,7 +1376,7 @@ checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0"
[[package]]
name = "sms-gateway"
version = "0.3.2"
version = "0.4.0"
dependencies = [
"actix-rt",
"actix-web",
......
......@@ -2,7 +2,7 @@
name = "sms-gateway"
description = "A http frontend for SMS Server Tools 3"
authors = ["David Huss <david.huss@hfbk-hamburg.de>"]
version = "0.4.0"
version = "0.4.1"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
......
......@@ -31,10 +31,16 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
match args.len() {
2 | 3 => {
let kind = args[0].to_ascii_lowercase();
let path = PathBuf::from(&args[1]);
let kind = args[1].to_ascii_lowercase();
let path = PathBuf::from(&args[2]);
let content = std::fs::read_to_string(&path)?;
let content = match std::fs::read_to_string(&path) {
Ok(s) => s,
Err(e) => {
error!("Could not read {} SMS from path \"{}\": {}", kind, path.to_string_lossy(), e);
exit(1);
}
};
match &kind[..] {
"received" => {
......
......@@ -15,6 +15,8 @@ pub enum SmsError {
InvalidCharacters,
#[error("Could not write the SMS to the outgoing directory: '{0}'")]
WriteError(String),
#[error("Could not read SMS at path \"{0}\": {1}")]
ReadError(String, String),
#[error("Received Event of unknown kind: '{0}'")]
UnknownEventKind(String),
#[error("Failed to deserialize SMS from string: '{0}'")]
......@@ -33,6 +35,7 @@ impl SmsError {
SmsError::InvaldNumber(_s) => "Bad Request".to_string(),
SmsError::InvalidCharacters => "Bad Request".to_string(),
SmsError::WriteError(_s) => "Internal Server Error".to_string(),
SmsError::ReadError(_s, _x) => "Internal Server Error".to_string(),
SmsError::UnknownEventKind(_s) => "Internal Server Error".to_string(),
SmsError::DeserializationError(_s) => "Internal Server Error".to_string(),
SmsError::NotInWhiteList(_) => "Forbidden".to_string(),
......@@ -60,6 +63,7 @@ impl ResponseError for SmsError {
SmsError::InvaldNumber(_) => StatusCode::BAD_REQUEST,
SmsError::InvalidCharacters => StatusCode::BAD_REQUEST,
SmsError::WriteError(_) => StatusCode::INTERNAL_SERVER_ERROR,
SmsError::ReadError(..) => StatusCode::INTERNAL_SERVER_ERROR,
SmsError::UnknownEventKind(_) => StatusCode::INTERNAL_SERVER_ERROR,
SmsError::DeserializationError(_) => StatusCode::INTERNAL_SERVER_ERROR,
SmsError::NotInWhiteList(_) => StatusCode::FORBIDDEN,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment