blob: ea2fd5f17876d566521598003c9aff7094f5089f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
import Foundation
/// Errors that can occur during Bubomb payload validation, execution, and persistence.
public enum ExecutionError: LocalizedError, Equatable, Sendable {
case noPayloadConfigured
case invalidConfiguration(String)
case executableNotFound(String)
case scriptNotFound(String)
case workingDirectoryNotFound(String)
case invalidURL(String)
case permissionDenied(String)
case nonZeroExitStatus(Int, output: String)
case timeout(TimeInterval)
case cancelled
case processLaunchFailed(String)
case duplicateExecution
case destructiveActionRejected
case stepFailed(stepIndex: Int, stepName: String, reason: String)
case applicationNotFound(String)
case applicationLaunchFailed(String)
public var errorDescription: String? {
switch self {
case .noPayloadConfigured:
return "No payload configured. Open Settings to set up an action."
case .invalidConfiguration(let details):
return "Invalid configuration: \(details)"
case .executableNotFound(let path):
return "Executable not found at path: \(path)"
case .scriptNotFound(let path):
return "Script file not found at path: \(path)"
case .workingDirectoryNotFound(let path):
return "Working directory does not exist: \(path)"
case .invalidURL(let url):
return "Invalid URL: \(url). Only valid http:// and https:// URLs are supported."
case .permissionDenied(let path):
return "Permission denied accessing: \(path)"
case .nonZeroExitStatus(let code, let output):
let trimmed = output.trimmingCharacters(in: .whitespacesAndNewlines)
if trimmed.isEmpty {
return "Command failed with exit status \(code)."
} else {
let firstLine = trimmed.components(separatedBy: .newlines).first ?? ""
return "Command failed with exit status \(code): \(firstLine)"
}
case .timeout(let duration):
return "Execution timed out after \(String(format: "%.1f", duration)) seconds."
case .cancelled:
return "Execution was cancelled by the user."
case .processLaunchFailed(let details):
return "Failed to launch process: \(details)"
case .duplicateExecution:
return "A payload is already running. Wait for it to finish or cancel it."
case .destructiveActionRejected:
return "Destructive action was rejected by the user."
case .stepFailed(let index, let name, let reason):
return "Step \(index + 1) ('\(name)') failed: \(reason)"
case .applicationNotFound(let path):
return "Application not found at path: \(path)"
case .applicationLaunchFailed(let details):
return "Failed to open application: \(details)"
}
}
}
|