style(downloads): Made all errors type-based

Signed-off-by: quexeky <git@quexeky.dev>
This commit is contained in:
quexeky
2024-11-18 13:21:20 +11:00
parent bd3deacf38
commit ec2f4148e8
9 changed files with 89 additions and 100 deletions

View File

@ -148,7 +148,7 @@ pub fn download_game_chunk(
.get(chunk_url)
.header("Authorization", header)
.send()
.map_err(|e| GameDownloadError::CommunicationError(e.into()))?;
.map_err(|e| GameDownloadError::Communication(e.into()))?;
let mut destination = DropWriter::new(ctx.path);
@ -160,11 +160,7 @@ pub fn download_game_chunk(
let content_length = response.content_length();
if content_length.is_none() {
return Err(GameDownloadError::CommunicationError(
RemoteAccessError::GenericErrror(
"Invalid download endpoint, missing Content-Length header.".to_owned(),
),
));
return Err(GameDownloadError::Communication(RemoteAccessError::InvalidResponse));
}
let mut pipeline = DropDownloadPipeline::new(
@ -184,7 +180,7 @@ pub fn download_game_chunk(
let res = hex::encode(checksum.0);
if res != ctx.checksum {
return Err(GameDownloadError::ChecksumError);
return Err(GameDownloadError::Checksum);
}
Ok(true)