feat: quit preview gracefully if Info.plist not found
This commit is contained in:
@@ -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
14
src/RuntimeError.swift
Normal 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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user