Avoid panics (#392)

- Use `Result` as much as possible
- Display errors instead of panicking

TODO (maybe in another PR? this one is already quite big):
- Find a way to merge Ructe/ErrorPage types, so that we can have routes returning `Result<X, ErrorPage>` instead of panicking when we have an `Error`
- Display more details about the error, to make it easier to debug

(sorry, this isn't going to be fun to review, the diff is huge, but it is always the same changes)
This commit is contained in:
Baptiste Gelez
2018-12-29 09:36:07 +01:00
committed by GitHub
parent 4059a840be
commit 80a4dae8bd
50 changed files with 1879 additions and 1990 deletions
+1 -1
View File
@@ -59,5 +59,5 @@ fn new<'a>(args: &ArgMatches<'a>, conn: &Connection) {
open_registrations: open_reg,
short_description_html: String::new(),
long_description_html: String::new()
});
}).expect("Couldn't save instance");
}
+1 -1
View File
@@ -94,7 +94,7 @@ fn refill<'a>(args: &ArgMatches<'a>, conn: &Connection, searcher: Option<Searche
let len = posts.len();
for (i,post) in posts.iter().enumerate() {
println!("Importing {}/{} : {}", i+1, len, post.title);
searcher.update_document(conn, &post);
searcher.update_document(conn, &post).expect("Couldn't import post");
}
println!("Commiting result");
searcher.commit();
+3 -2
View File
@@ -72,6 +72,7 @@ fn new<'a>(args: &ArgMatches<'a>, conn: &Connection) {
admin,
&bio,
email,
User::hash_pass(&password),
).update_boxes(conn);
User::hash_pass(&password).expect("Couldn't hash password"),
).expect("Couldn't save new user")
.update_boxes(conn).expect("Couldn't update ActivityPub informations for new user");
}