@@ -163,11 +163,11 @@ final class DownloadQueueObserver: CKDownloadQueueObserver {
163163 try manuallyInstall ( appNameAndVersion: metadata. appNameAndVersion)
164164 } else {
165165 guard !status. isFailed else {
166- throw MASError . runtimeError ( " Failed to download \( metadata. appNameAndVersion) " )
166+ throw MASError . error ( " Failed to download \( metadata. appNameAndVersion) " )
167167 }
168168 guard !status. isCancelled else {
169169 guard shouldCancel ( download, false ) else {
170- throw MASError . runtimeError ( " Download cancelled for \( metadata. appNameAndVersion) " )
170+ throw MASError . error ( " Download cancelled for \( metadata. appNameAndVersion) " )
171171 }
172172
173173 completionHandler ? ( )
@@ -221,18 +221,18 @@ final class DownloadQueueObserver: CKDownloadQueueObserver {
221221
222222 private func manuallyInstall( appNameAndVersion: String ) throws {
223223 guard pkgHardLinkURL != nil else {
224- throw MASError . runtimeError ( " Failed to find pkg to install for \( appNameAndVersion) " )
224+ throw MASError . error ( " Failed to find pkg to install for \( appNameAndVersion) " )
225225 }
226226 guard receiptHardLinkURL != nil else {
227- throw MASError . runtimeError ( " Failed to find receipt to import for \( appNameAndVersion) " )
227+ throw MASError . error ( " Failed to find receipt to import for \( appNameAndVersion) " )
228228 }
229229
230230 try spotlightImport ( appNameAndVersion: appNameAndVersion, from: try install ( appNameAndVersion: appNameAndVersion) )
231231 }
232232
233233 private func install( appNameAndVersion: String ) throws -> URL {
234234 guard let pkgHardLinkPath = pkgHardLinkURL? . path else {
235- throw MASError . runtimeError ( " Failed to find pkg to install for \( appNameAndVersion) " )
235+ throw MASError . error ( " Failed to find pkg to install for \( appNameAndVersion) " )
236236 }
237237
238238 let process = Process ( )
@@ -245,15 +245,15 @@ final class DownloadQueueObserver: CKDownloadQueueObserver {
245245 do {
246246 try run ( asEffectiveUID: 0 , andEffectiveGID: 0 ) { try process. run ( ) }
247247 } catch {
248- throw MASError . runtimeError ( " Failed to install \( appNameAndVersion) from \( pkgHardLinkPath) " , error: error)
248+ throw MASError . error ( " Failed to install \( appNameAndVersion) from \( pkgHardLinkPath) " , error: error)
249249 }
250250 process. waitUntilExit ( )
251251 let standardOutputText =
252252 String ( data: standardOutputPipe. fileHandleForReading. readDataToEndOfFile ( ) , encoding: . utf8) ?? " "
253253 let standardErrorText =
254254 String ( data: standardErrorPipe. fileHandleForReading. readDataToEndOfFile ( ) , encoding: . utf8) ?? " "
255255 guard process. terminationStatus == 0 else {
256- throw MASError . runtimeError (
256+ throw MASError . error (
257257 """
258258 Failed to install \( appNameAndVersion) from \( pkgHardLinkPath)
259259 Exit status: \( process. terminationStatus) \(
@@ -269,15 +269,15 @@ final class DownloadQueueObserver: CKDownloadQueueObserver {
269269 appFolderURLNSRange. location != NSNotFound,
270270 let appFolderURLRange = Range ( appFolderURLNSRange, in: standardErrorText)
271271 else { // swiftformat:enable indent
272- throw MASError . runtimeError (
272+ throw MASError . error (
273273 " Failed to find app folder URL in installer output for \( appNameAndVersion) " ,
274274 error: standardErrorText
275275 )
276276 }
277277
278278 let appFolderURLString = String ( standardErrorText [ appFolderURLRange] )
279279 guard let appFolderURL = URL ( string: appFolderURLString) else {
280- throw MASError . runtimeError (
280+ throw MASError . error (
281281 " Failed to parse app folder URL for \( appNameAndVersion) from \( appFolderURLString) " ,
282282 error: standardErrorText
283283 )
@@ -288,10 +288,10 @@ final class DownloadQueueObserver: CKDownloadQueueObserver {
288288
289289 private func spotlightImport( appNameAndVersion: String , from appFolderURL: URL ) throws {
290290 guard let receiptHardLinkURL else {
291- throw MASError . runtimeError ( " Failed to find receipt to import for \( appNameAndVersion) " )
291+ throw MASError . error ( " Failed to find receipt to import for \( appNameAndVersion) " )
292292 }
293293 guard let pkgHardLinkPath = pkgHardLinkURL? . path else {
294- throw MASError . runtimeError ( " Failed to find pkg to install for \( appNameAndVersion) " )
294+ throw MASError . error ( " Failed to find pkg to install for \( appNameAndVersion) " )
295295 }
296296
297297 let receiptURL = appFolderURL. appendingPathComponent ( " Contents/_MASReceipt/receipt " , isDirectory: false )
@@ -303,7 +303,7 @@ final class DownloadQueueObserver: CKDownloadQueueObserver {
303303 try fileManager. setAttributes ( [ . ownerAccountID: 0 , . groupOwnerAccountID: 0 ] , ofItemAtPath: receiptURL. path)
304304 }
305305 } catch {
306- throw MASError . runtimeError (
306+ throw MASError . error (
307307 """
308308 Failed to copy receipt for \( appNameAndVersion) from \( receiptHardLinkURL. path. quoted) to \
309309 \( receiptURL. path. quoted)
@@ -322,11 +322,11 @@ final class DownloadQueueObserver: CKDownloadQueueObserver {
322322 do {
323323 try process. run ( )
324324 } catch {
325- throw MASError . runtimeError ( " Failed to install \( appNameAndVersion) from \( pkgHardLinkPath) " , error: error)
325+ throw MASError . error ( " Failed to install \( appNameAndVersion) from \( pkgHardLinkPath) " , error: error)
326326 }
327327 process. waitUntilExit ( )
328328 guard process. terminationStatus == 0 else {
329- throw MASError . runtimeError (
329+ throw MASError . error (
330330 """
331331 Failed to install \( appNameAndVersion) from \( pkgHardLinkPath)
332332 Exit status: \( process. terminationStatus) \(
@@ -402,12 +402,12 @@ private extension URL {
402402 return false
403403 }
404404 guard let fileResourceID1 = try resourceValues ( forKeys: [ . fileResourceIdentifierKey] ) . fileResourceIdentifier else {
405- throw MASError . runtimeError ( " Failed to get file resource identifier for \( path) " )
405+ throw MASError . error ( " Failed to get file resource identifier for \( path) " )
406406 }
407407 guard
408408 let fileResourceID2 = try url. resourceValues ( forKeys: [ . fileResourceIdentifierKey] ) . fileResourceIdentifier
409409 else {
410- throw MASError . runtimeError ( " Failed to get file resource identifier for \( url. path) " )
410+ throw MASError . error ( " Failed to get file resource identifier for \( url. path) " )
411411 }
412412
413413 return fileResourceID1. isEqual ( fileResourceID2)
0 commit comments