@@ -38,32 +38,33 @@ func (u *Unit) Write(data []byte) (int, error) {
3838
3939type Units []Unit
4040
41- func Run (option Option ) {
41+ func Run (option Option ) error {
4242 fmt .Printf ("%+v\n " , option )
4343 err := option .checkingHeaders ()
4444 if err != nil {
45- fmt .Errorf ("%s" , err )
45+ return fmt .Errorf ("%s" , err )
4646 }
4747
4848 option .divide ()
4949
5050 tmpDir , err := ioutil .TempDir ("" , "rget" )
5151 if err != nil {
52- fmt .Errorf ("%s" , err )
52+ return fmt .Errorf ("%s" , err )
5353 }
5454 defer os .RemoveAll (tmpDir )
5555 fmt .Println (tmpDir )
5656
5757 err = option .parallelDownload (tmpDir )
5858 if err != nil {
59- fmt .Errorf ("%s" , err )
59+ return fmt .Errorf ("%s" , err )
6060 }
6161
6262 err = option .combine (tmpDir )
6363 if err != nil {
64- fmt .Errorf ("%s" , err )
64+ return fmt .Errorf ("%s" , err )
6565 }
6666
67+ return nil
6768}
6869
6970func (o * Option ) checkingHeaders () error {
@@ -173,6 +174,8 @@ func (o *Option) downloadWithContext(
173174 req .Header .Set ("Range" , byteRange )
174175
175176 client := http .DefaultClient
177+ // TODO: should check resp.StatusCode.
178+ // client.Do cannot seems to return the err when statusCode is 50x etc.
176179 resp , err := client .Do (req )
177180 if err != nil {
178181 fmt .Printf ("client err: %s" , err )
0 commit comments