v0.4.8 better errors #9

Open
Quaternions wants to merge 7 commits from staging into master
Showing only changes of commit 81f411272f - Show all commits

View File

@ -58,7 +58,12 @@ impl std::fmt::Display for UploadError{
}
}
impl std::error::Error for UploadError{}
type UploadResponse=u64;
type RobloxUploadResponse=u64;
#[derive(Debug,serde::Deserialize,serde::Serialize)]
#[allow(nonstandard_style,dead_code)]
pub struct UploadResponse{
pub AssetId:u64,
}
#[allow(nonstandard_style,dead_code)]
pub struct GetAssetRequest{
@ -267,11 +272,14 @@ impl CookieContext{
query.append_pair("groupId",group_id.to_string().as_str());
}
}
crate::response_ok(
let asset_id=crate::response_ok(
self.post(url,body).await.map_err(CreateError::PostError)?
).await.map_err(CreateError::Response)?
.json::<UploadResponse>().await.map_err(CreateError::Reqwest)
.json::<RobloxUploadResponse>().await.map_err(CreateError::Reqwest)?;
Ok(UploadResponse{
AssetId:asset_id,
})
}
pub async fn upload(&self,config:UploadRequest,body:impl Into<reqwest::Body>+Clone)->Result<UploadResponse,UploadError>{
let mut url=reqwest::Url::parse("https://data.roblox.com/Data/Upload.ashx?json=1&type=Model&genreTypeId=1").map_err(UploadError::ParseError)?;
@ -299,11 +307,14 @@ impl CookieContext{
query.append_pair("groupId",group_id.to_string().as_str());
}
}
crate::response_ok(
let asset_id=crate::response_ok(
self.post(url,body).await.map_err(UploadError::PostError)?
).await.map_err(UploadError::Response)?
.json::<UploadResponse>().await.map_err(UploadError::Reqwest)
.json::<RobloxUploadResponse>().await.map_err(UploadError::Reqwest)?;
Ok(UploadResponse{
AssetId:asset_id,
})
}
pub async fn get_asset(&self,config:GetAssetRequest)->Result<Vec<u8>,GetError>{
let mut url=reqwest::Url::parse("https://assetdelivery.roblox.com/v1/asset/").map_err(GetError::ParseError)?;