simplify retrieval in find_by_host()
we can use "first()" instead of limit(1).load().etc… since on a UNIQUE field, we only expect 1 result. first() returns QueryResult, which is Result<T, diesel::Error>, so we need to implement a converter for that error type. This commit addresses @fdb-hiroshima's review.
This commit is contained in:
@@ -14,6 +14,12 @@ impl From<Error> for ErrorPage {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<diesel::result::Error> for ErrorPage {
|
||||
fn from(err: diesel::result::Error) -> ErrorPage {
|
||||
ErrorPage(plume_models::Error::Db(err))
|
||||
}
|
||||
}
|
||||
|
||||
impl<'r> Responder<'r> for ErrorPage {
|
||||
fn respond_to(self, req: &Request) -> response::Result<'r> {
|
||||
let rockets = req.guard::<PlumeRocket>().unwrap();
|
||||
|
||||
Reference in New Issue
Block a user