@@ -5,25 +5,6 @@ use libsemverator::semver::Semver as Version;
55use reqwest:: Url ;
66use std:: error:: Error ;
77
8- // Custom error for download issues
9- #[ derive( Debug ) ]
10- pub struct DownloadError {
11- pub status : u16 ,
12- pub src : String ,
13- }
14-
15- impl std:: fmt:: Display for DownloadError {
16- fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
17- write ! (
18- f,
19- "Download error: status code {} from {}" ,
20- self . status, self . src
21- )
22- }
23- }
24-
25- impl Error for DownloadError { }
26-
278// Select function to pick a version
289pub async fn select ( rq : & PackageReq , config : & Config ) -> Result < Option < Version > , Box < dyn Error > > {
2910 let versions = ls ( & rq. project , config) . await ?;
@@ -45,14 +26,11 @@ pub async fn ls(project: &String, config: &Config) -> Result<Vec<Version>, Box<d
4526 base_url, project, platform, arch
4627 ) ) ?;
4728
48- let rsp = build_client ( ) ?. get ( url. clone ( ) ) . send ( ) . await ?;
49-
50- if !rsp. status ( ) . is_success ( ) {
51- return Err ( Box :: new ( DownloadError {
52- status : rsp. status ( ) . as_u16 ( ) ,
53- src : url. to_string ( ) ,
54- } ) ) ;
55- }
29+ let rsp = build_client ( ) ?
30+ . get ( url. clone ( ) )
31+ . send ( )
32+ . await ?
33+ . error_for_status ( ) ?;
5634
5735 let releases = rsp. text ( ) . await ?;
5836 let mut versions: Vec < Version > = releases
@@ -63,8 +41,8 @@ pub async fn ls(project: &String, config: &Config) -> Result<Vec<Version>, Box<d
6341
6442 if versions. is_empty ( ) {
6543 return Err ( Box :: new ( std:: io:: Error :: new (
66- std:: io:: ErrorKind :: Other ,
67- format ! ( "No versions for {}" , project) ,
44+ std:: io:: ErrorKind :: NotFound ,
45+ format ! ( "No inventory for {}" , project) ,
6846 ) ) ) ;
6947 }
7048
0 commit comments