items_group: use CatalogError
@@ -2,8 +2,7 @@ use crate::state_types::*;
use crate::types::addons::{Descriptor, ResourceRequest, ResourceResponse};
use serde_derive::*;
use std::convert::TryInto;
-
-pub const UNEXPECTED_RESP_MSG: &str = "unexpected ResourceResponse";
+use super::CatalogError;
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
#[serde(tag = "type", content = "content")]
@@ -21,8 +20,7 @@ impl<R, E> Default for Loadable<R, E> {
#[derive(Debug, Serialize, Clone)]
pub struct ItemsGroup<T> {
req: ResourceRequest,
- // @TODO: Use the CatalogError type
- pub content: Loadable<T, String>,
+ pub content: Loadable<T, CatalogError>,
}
impl<T> Group for ItemsGroup<T>
where
@@ -38,9 +36,9 @@ where
self.content = match res {
Ok(resp) => match resp.to_owned().try_into() {
Ok(x) => Loadable::Ready(x),
- Err(_) => Loadable::Err(UNEXPECTED_RESP_MSG.to_string()),
+ Err(_) => Loadable::Err(CatalogError::UnexpectedResp),
},
- Err(e) => Loadable::Err(e.to_string()),
+ Err(e) => Loadable::Err(CatalogError::Other(e.to_string())),
};
}
fn addon_req(&self) -> &ResourceRequest {
