88from dvc .config import Config
99from dvc .config import ConfigError
1010from dvc .exceptions import DvcException
11+ from dvc .exceptions import HTTPErrorStatusCodeException
1112from dvc .progress import Tqdm
1213from dvc .remote .base import RemoteBASE
1314from dvc .scheme import Schemes
@@ -37,7 +38,11 @@ def __init__(self, repo, config):
3738 )
3839
3940 def _download (self , from_info , to_file , name = None , no_progress_bar = False ):
40- request = self ._request ("GET" , from_info .url , stream = True )
41+ response = self ._request ("GET" , from_info .url , stream = True )
42+ if response .status_code != 200 :
43+ raise HTTPErrorStatusCodeException (
44+ response .status_code , response .reason
45+ )
4146 with Tqdm (
4247 total = None if no_progress_bar else self ._content_length (from_info ),
4348 leave = False ,
@@ -46,7 +51,7 @@ def _download(self, from_info, to_file, name=None, no_progress_bar=False):
4651 disable = no_progress_bar ,
4752 ) as pbar :
4853 with open (to_file , "wb" ) as fd :
49- for chunk in request .iter_content (chunk_size = self .CHUNK_SIZE ):
54+ for chunk in response .iter_content (chunk_size = self .CHUNK_SIZE ):
5055 fd .write (chunk )
5156 fd .flush ()
5257 pbar .update (len (chunk ))
0 commit comments