feat: quit preview gracefully if Info.plist not found

This commit is contained in:
relikd
2025-11-06 01:52:05 +01:00
parent cfb6b17bc7
commit 21c21ec059
4 changed files with 24 additions and 3 deletions

View File

@@ -7,9 +7,11 @@ struct PreviewGenerator {
var data: [String: String] = [:] // used for TAG replacements
let meta: MetaInfo
init(_ meta: MetaInfo) {
init(_ meta: MetaInfo) throws {
self.meta = meta
let plistApp = meta.readPlistApp()
guard let plistApp = meta.readPlistApp() else {
throw RuntimeError("Info.plist not found")
}
let plistProvision = meta.readPlistProvision()
data["QuickLookTitle"] = stringForFileType(meta)

14
src/RuntimeError.swift Normal file
View File

@@ -0,0 +1,14 @@
import Foundation
// used to quit QuickLook generation without returning a valid preview
struct RuntimeError: LocalizedError {
let description: String
init(_ description: String) {
self.description = description
}
var errorDescription: String? {
description
}
}