@@ -33,12 +33,14 @@ #import "OFHTTPRequestFailedException.h" #import "OFInvalidFormatException.h" #import "OFInvalidServerReplyException.h" #import "OFOpenItemFailedException.h" #import "OFOutOfRangeException.h" +#import "OFReadFailedException.h" #import "OFStatItemFailedException.h" #import "OFUnsupportedProtocolException.h" +#import "OFWriteFailedException.h" #import "ProgressBar.h" #define GIBIBYTE (1024 * 1024 * 1024) #define MEBIBYTE (1024 * 1024) @@ -290,21 +292,10 @@ request = [OFHTTPRequest requestWithURL: URL]; [request setHeaders: clientHeaders]; @try { response = [_HTTPClient performRequest: request]; - } @catch (OFHTTPRequestFailedException *e) { - if (!_quiet) - [of_stdout writeFormat: @" ➜ %d\n", - [[e response] statusCode]]; - - [of_stderr writeFormat: @"%@: Failed to download <%@>!\n", - [OFApplication programName], - [URL string]]; - - _errorCode = 1; - goto next; } @catch (OFAddressTranslationFailedException *e) { if (!_quiet) [of_stdout writeString: @"\n"]; [of_stderr writeFormat: @"%@: Failed to download <%@>!\n" @@ -346,10 +337,39 @@ @"for ObjFW\n such as ObjOpenSSL!\n", [OFApplication programName]]; _errorCode = 1; goto next; + } @catch (OFReadOrWriteFailedException *e) { + OFString *action = @"Read or write"; + + if (!_quiet) + [of_stdout writeString: @"\n"]; + + if ([e isKindOfClass: [OFReadFailedException class]]) + action = @"Read"; + else if ([e isKindOfClass: [OFWriteFailedException class]]) + action = @"Write"; + + [of_stderr writeFormat: @"%@: Failed to download <%@>!\n" + @" %@ failed: %@\n", + [OFApplication programName], + [URL string], action, e]; + + _errorCode = 1; + goto next; + } @catch (OFHTTPRequestFailedException *e) { + if (!_quiet) + [of_stdout writeFormat: @" ➜ %d\n", + [[e response] statusCode]]; + + [of_stderr writeFormat: @"%@: Failed to download <%@>!\n", + [OFApplication programName], + [URL string]]; + + _errorCode = 1; + goto next; } if (!_quiet) [of_stdout writeFormat: @" ➜ %d\n", [response statusCode]]; @@ -363,19 +383,19 @@ if (!_quiet) { if (type == nil) type = @"unknown"; if (lengthString != nil) { - if (_length >= GIBIBYTE) + if (_resumedFrom + _length >= GIBIBYTE) lengthString = [OFString stringWithFormat: @"%.2f GiB", (float)(_resumedFrom + _length) / GIBIBYTE]; - else if (_length >= MEBIBYTE) + else if (_resumedFrom + _length >= MEBIBYTE) lengthString = [OFString stringWithFormat: @"%.2f MiB", (float)(_resumedFrom + _length) / MEBIBYTE]; - else if (_length >= KIBIBYTE) + else if (_resumedFrom + _length >= KIBIBYTE) lengthString = [OFString stringWithFormat: @"%.2f KiB", (float)(_resumedFrom + _length) / KIBIBYTE]; else lengthString = [OFString stringWithFormat: