less strict errors
This commit is contained in:
parent
154ee79864
commit
d623dd5ce8
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -1027,7 +1027,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ffplayout-api"
|
name = "ffplayout-api"
|
||||||
version = "0.4.0"
|
version = "0.4.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"actix-multipart",
|
"actix-multipart",
|
||||||
"actix-web",
|
"actix-web",
|
||||||
|
@ -4,7 +4,7 @@ description = "Rest API for ffplayout"
|
|||||||
license = "GPL-3.0"
|
license = "GPL-3.0"
|
||||||
authors = ["Jonathan Baecker jonbae77@gmail.com"]
|
authors = ["Jonathan Baecker jonbae77@gmail.com"]
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
version = "0.4.0"
|
version = "0.4.1"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
@ -130,7 +130,7 @@ where
|
|||||||
Ok(result) => Ok(result),
|
Ok(result) => Ok(result),
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
error!("{e:?}");
|
error!("{e:?}");
|
||||||
Err(ServiceError::BadRequest(e.to_string()))
|
Err(ServiceError::ServiceUnavailable(e.to_string()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,9 @@ pub enum ServiceError {
|
|||||||
|
|
||||||
#[display(fmt = "NoContent: {}", _0)]
|
#[display(fmt = "NoContent: {}", _0)]
|
||||||
NoContent(String),
|
NoContent(String),
|
||||||
|
|
||||||
|
#[display(fmt = "ServiceUnavailable: {}", _0)]
|
||||||
|
ServiceUnavailable(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
// impl ResponseError trait allows to convert our errors into http responses with appropriate data
|
// impl ResponseError trait allows to convert our errors into http responses with appropriate data
|
||||||
@ -30,6 +33,9 @@ impl ResponseError for ServiceError {
|
|||||||
ServiceError::Conflict(ref message) => HttpResponse::Conflict().json(message),
|
ServiceError::Conflict(ref message) => HttpResponse::Conflict().json(message),
|
||||||
ServiceError::Unauthorized => HttpResponse::Unauthorized().json("No Permission!"),
|
ServiceError::Unauthorized => HttpResponse::Unauthorized().json("No Permission!"),
|
||||||
ServiceError::NoContent(ref message) => HttpResponse::NoContent().json(message),
|
ServiceError::NoContent(ref message) => HttpResponse::NoContent().json(message),
|
||||||
|
ServiceError::ServiceUnavailable(ref message) => {
|
||||||
|
HttpResponse::ServiceUnavailable().json(message)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -54,7 +60,7 @@ impl From<actix_multipart::MultipartError> for ServiceError {
|
|||||||
|
|
||||||
impl From<std::io::Error> for ServiceError {
|
impl From<std::io::Error> for ServiceError {
|
||||||
fn from(err: std::io::Error) -> ServiceError {
|
fn from(err: std::io::Error) -> ServiceError {
|
||||||
ServiceError::BadRequest(err.to_string())
|
ServiceError::NoContent(err.to_string())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ pub async fn browser(id: i64, path_obj: &PathObject) -> Result<PathObject, Servi
|
|||||||
Ok(p) => p.filter_map(|r| r.ok()).collect(),
|
Ok(p) => p.filter_map(|r| r.ok()).collect(),
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
error!("{e} in {}", path_obj.source);
|
error!("{e} in {}", path_obj.source);
|
||||||
return Err(ServiceError::InternalServerError);
|
return Err(ServiceError::NoContent(e.to_string()));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -217,7 +217,7 @@ pub async fn read_log_file(channel_id: &i64, date: &str) -> Result<String, Servi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Err(ServiceError::BadRequest(
|
Err(ServiceError::NoContent(
|
||||||
"Requested log file not exists, or not readable.".to_string(),
|
"Requested log file not exists, or not readable.".to_string(),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user