diff --git a/entity_api/src/organization.rs b/entity_api/src/organization.rs index 2053a71..d07b17a 100644 --- a/entity_api/src/organization.rs +++ b/entity_api/src/organization.rs @@ -9,10 +9,10 @@ pub async fn find_all(db: &DatabaseConnection) -> Vec { } pub async fn find_by_id(db: &DatabaseConnection, id: i32) -> Result, Error> { - match Entity::find_by_id(id).one(db).await { - Ok(result) => Ok(result), - Err(error) => Err(error.into()), - } + Entity::find_by_id(id) + .one(db) + .await + .map_err(|err| err.into()) } pub(crate) async fn seed_database(db: &DatabaseConnection) { diff --git a/web/src/controller/organization_controller.rs b/web/src/controller/organization_controller.rs index f09c6f0..ed7bcdf 100644 --- a/web/src/controller/organization_controller.rs +++ b/web/src/controller/organization_controller.rs @@ -36,10 +36,9 @@ impl OrganizationController { debug!("GET Organization by id: {}", id); let organization: Result, Error> = - match OrganizationApi::find_by_id(&app_state.database_connection.unwrap(), id).await { - Ok(result) => Ok(result), - Err(error) => Err(error.into()), - }; + OrganizationApi::find_by_id(&app_state.database_connection.unwrap(), id) + .await + .map_err(|err| err.into()); Json(organization) }