         // Fetch download info by identifier
         if let downloadInfo = DownloadInfo.fetchDownloadInfo(with: task.taskIdentifier) {
             downloadInfo.setValue(DownloadInfoStatus.failed, forKey: DownloadInfo.Keys.status)
+            saveData()
         }
-        saveData()
         // Send notification about error
-        // Do we need to send user info?
-        NotificationCenter.default.post(name: .didFailDownload, object: nil)
+        guard let downloadTask = task as? URLSessionDownloadTask,
+            let downloadURL = downloadedUrls[downloadTask] else { return }
+        let userInfoDict = ["url": downloadURL]
+        NotificationCenter.default.post(name: .didFailDownload, object: nil, userInfo: userInfoDict)
     }
 
 }

        saveData()
        // Send notification that download is complete
        // Do we need to send user info?
        NotificationCenter.default.post(name: .didCompleteDownload, object: nil)
    }

    func urlSession(_ session: URLSession, downloadTask: URLSessionDownloadTask, didWriteData bytesWritten: Int64,
                    totalBytesWritten: Int64, totalBytesExpectedToWrite: Int64) {
        if totalBytesExpectedToWrite > 0 {
            let progress = Float(totalBytesWritten) / Float(totalBytesExpectedToWrite)
            let progressDict = ["progress": progress]
            // Send download progress notification
            NotificationCenter.default.post(name: .didUpdateDownloadProgress, object: nil, userInfo: progressDict)
        }
    }


    func urlSession(_ session: URLSession, downloadTask: URLSessionDownloadTask, didFinishDownloadingTo location: URL) {
        guard let appDelegate = UIApplication.shared.delegate as? AppDelegate,
            let entity = NSEntityDescription.entity(forEntityName: DownloadInfo.Keys.entityName,
                                                    in: appDelegate.dataController.managedObjectContext),
            let downloadURL = downloadedUrls[downloadTask]
            else { return }
        let downloadInfo = NSManagedObject(entity: entity, insertInto: appDelegate.dataController.managedObjectContext)
        downloadInfo.setValuesForKeys([
