diff --git a/TestApp/Sources/App/AppModule.swift b/TestApp/Sources/App/AppModule.swift index 22c29235f..4b6fc0f03 100644 --- a/TestApp/Sources/App/AppModule.swift +++ b/TestApp/Sources/App/AppModule.swift @@ -78,11 +78,18 @@ extension AppModule: ModuleDelegate { guard let error = error else { return } if case LibraryError.cancelled = error { return } - print("Error: \(error)") + var message = "" + if let error = (error as? LocalizedError)?.errorDescription { + message += error + "\n\n" + } + + var desc = "" + dump(error, to: &desc) + message += desc presentAlert( NSLocalizedString("error_title", comment: "Alert title for errors"), - message: error.localizedDescription, + message: message, from: viewController ) } diff --git a/TestApp/Sources/Library/LibraryError.swift b/TestApp/Sources/Library/LibraryError.swift index 092bc5dac..cbbab29da 100644 --- a/TestApp/Sources/Library/LibraryError.swift +++ b/TestApp/Sources/Library/LibraryError.swift @@ -29,7 +29,11 @@ enum LibraryError: LocalizedError { return String(format: NSLocalizedString("library_error_openFailed", comment: "Error message used when a low-level error occured while opening a publication"), error.localizedDescription) case let .downloadFailed(error): return String(format: NSLocalizedString("library_error_downloadFailed", comment: "Error message when the download of a publication failed"), error?.localizedDescription ?? "None") - default: + case .bookDeletionFailed: + return NSLocalizedString("library_error_bookDeletionFailed", comment: "Error message when the deletion of a publication failed") + case .publicationIsRestricted: + return NSLocalizedString("library_error_publicationIsRestricted", comment: "Error message when the publication is still restricted") + case .cancelled: return nil } } diff --git a/TestApp/Sources/Resources/en.lproj/Localizable.strings b/TestApp/Sources/Resources/en.lproj/Localizable.strings index 36a72dbd8..d7937c0be 100644 --- a/TestApp/Sources/Resources/en.lproj/Localizable.strings +++ b/TestApp/Sources/Resources/en.lproj/Localizable.strings @@ -69,6 +69,10 @@ "library_error_openFailed" = "Error while opening this publication: %@"; /* Error message when the download of a publication failed */ "library_error_downloadFailed" = "Download failed: %@"; +/* Error message when the deletion of a publication failed */ +"library_error_bookDeletionFailed" = "Failed to delete the publication"; +/* Error message when the publication is still restricted. */ +"library_error_publicationIsRestricted" = "You are not allowed to open this publication"; /* Accessibility label for the library collection view */ "library_a11y_label" = "Library";