File tree Expand file tree Collapse file tree
Source/TriangleDrawMain/Browser Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -243,12 +243,18 @@ extension BrowserViewController: UIDocumentBrowserViewControllerDelegate {
243243
244244 /// Informs the delegate that an import action failed.
245245 func documentBrowser( _ controller: UIDocumentBrowserViewController , failedToImportDocumentAt documentURL: URL , error: Error ? ) {
246- // Make sure to handle the failed import appropriately, e.g., by presenting an error message to the user.
247246 if let error = error {
248247 log. error ( " documentURL: ' \( documentURL) ' error: ' \( error) ' " )
249248 } else {
250249 log. error ( " documentURL: ' \( documentURL) ' error: nil " )
251250 }
251+
252+ // Show an error to the user
253+ let errorMessage : String = error. map { " \( $0) " } ?? " The error is 'nil'. No info provided. "
254+ let alert = UIAlertController ( title: " Error in failedToImportDocumentAt " , message: errorMessage, preferredStyle: . alert)
255+ let action = UIAlertAction ( title: " OK " , style: . default) { ( _) in }
256+ alert. addAction ( action)
257+ controller. present ( alert, animated: true )
252258 }
253259
254260 func documentBrowser( _ controller: UIDocumentBrowserViewController , applicationActivitiesForDocumentURLs documentURLs: [ URL ] ) -> [ UIActivity ] {
You can’t perform that action at this time.
0 commit comments