package com.novoda.downloadmanager;

class DownloadErrorFactory {

    private DownloadErrorFactory() {
        // Uses static factory methods.
    }

    static DownloadError createSizeMismatchError(DownloadFileStatus downloadFileStatus) {
        String sizeMismatchMessage = String.format(
                "Download File with ID: %s has a greater current size: %s than the total size: ",
                downloadFileStatus.downloadBatchId().rawId(),
                downloadFileStatus.bytesDownloaded(),
                downloadFileStatus.totalBytes()
        );
        return new DownloadError(DownloadError.Type.FILE_CURRENT_AND_TOTAL_SIZE_MISMATCH, sizeMismatchMessage);
    }

}

@@ -60,16 +60,66 @@
 tory %7B%0A%0A
+    private static final String NO_MESSAGE = %22%22;%0A%0A
     priv
@@ -143,24 +143,24 @@
 Factory() %7B%0A
-
         // U
@@ -431,16 +431,18 @@
 l size: 
+%25s
 %22,%0A     
@@ -611,16 +611,16 @@
      );%0A
-
         
@@ -730,10 +730,2301 @@
 %0A    %7D%0A%0A
+    static DownloadError createTotalSizeRequestFailedError(DownloadFileId downloadFileId, String url) %7B%0A        String totalSizeRequestFailedMessage = String.format(%0A                %22Total size request failed for File with ID: %25s and Request: %25s%22,%0A                downloadFileId.rawId(),%0A                url%0A        );%0A        return new DownloadError(DownloadError.Type.FILE_TOTAL_SIZE_REQUEST_FAILED, totalSizeRequestFailedMessage);%0A    %7D%0A%0A    static DownloadError createInsufficientFreeSpaceError(DownloadFileStatus downloadFileStatus) %7B%0A        String insufficientFreeSpaceMessage = String.format(%0A                %22Insufficient free space to create file with ID: %25s Bytes Required: %25s%22,%0A                downloadFileStatus.downloadFileId().rawId(),%0A                downloadFileStatus.totalBytes()%0A        );%0A        return new DownloadError(DownloadError.Type.FILE_CANNOT_BE_CREATED_LOCALLY_INSUFFICIENT_FREE_SPACE, insufficientFreeSpaceMessage);%0A    %7D%0A%0A    static DownloadError createCannotWriteToFileError(DownloadFileStatus downloadFileStatus) %7B%0A        String cannotWriteToFileMessage = String.format(%0A                %22Cannot write to file with Id: %25s%22,%0A                downloadFileStatus.downloadFileId().rawId()%0A        );%0A        return new DownloadError(DownloadError.Type.FILE_CANNOT_BE_WRITTEN, cannotWriteToFileMessage);%0A    %7D%0A%0A    static DownloadError createStorageNotAvailableError(FilePersistence filePersistence) %7B%0A        String storageUnavailableMessage = String.format(%0A                %22Storage with base path: %25s is not available%22,%0A                filePersistence.basePath()%0A        );%0A        return new DownloadError(DownloadError.Type.STORAGE_UNAVAILABLE, storageUnavailableMessage);%0A    %7D%0A%0A    static DownloadError createNetworkError(String networkErrorCause) %7B%0A        String networkErrorMessage = String.format(%0A                %22Network error, cannot download file. Cause: %25s%22,%0A                networkErrorCause%0A        );%0A        return new DownloadError(DownloadError.Type.STORAGE_UNAVAILABLE, networkErrorMessage);%0A    %7D%0A%0A    static DownloadError createUnknownError() %7B%0A        String unknownErrorMessage = %22Unknown download error, additional information unavailable.%22;%0A        return new DownloadError(DownloadError.Type.UNKNOWN, unknownErrorMessage);%0A    %7D%0A%0A
 %7D%0A

Add other download error types to the `DownloadErrorFactory.