mirror of
https://github.com/redlib-org/redlib.git
synced 2025-05-14 14:02:50 +00:00
Error Page
This commit is contained in:
parent
bc1b29246d
commit
39ba50dada
6 changed files with 31 additions and 40 deletions
|
@ -1,6 +1,6 @@
|
|||
// CRATES
|
||||
use crate::utils::{fetch_posts, format_num, format_url, param, request, val, ErrorTemplate, Post, Subreddit};
|
||||
use actix_web::{http::StatusCode, HttpRequest, HttpResponse, Result};
|
||||
use crate::utils::{error, fetch_posts, format_num, format_url, param, request, val, Post, Subreddit};
|
||||
use actix_web::{HttpRequest, HttpResponse, Result};
|
||||
use askama::Template;
|
||||
use std::convert::TryInto;
|
||||
|
||||
|
@ -29,12 +29,7 @@ pub async fn page(req: HttpRequest) -> Result<HttpResponse> {
|
|||
let posts = fetch_posts(path.clone(), String::new()).await;
|
||||
|
||||
if posts.is_err() {
|
||||
let s = ErrorTemplate {
|
||||
message: posts.err().unwrap().to_string(),
|
||||
}
|
||||
.render()
|
||||
.unwrap();
|
||||
Ok(HttpResponse::Ok().status(StatusCode::NOT_FOUND).content_type("text/html").body(s))
|
||||
error(posts.err().unwrap().to_string()).await
|
||||
} else {
|
||||
let sub = sub_result.unwrap_or(Subreddit::default());
|
||||
let items = posts.unwrap();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue