diff options
| author | gigagamerchaddhruv-spec <gigagamerchaddhruv-spec@users.noreply.github.com> | 2026-10-14 20:18:20 +0530 |
|---|---|---|
| committer | gigagamerchaddhruv-spec <gigagamerchaddhruv-spec@users.noreply.github.com> | 2026-10-14 20:18:20 +0530 |
| commit | aceca8b5dfc8edd378ee9ff891bccb0f94c69f31 (patch) | |
| tree | 08401ce8d050afbbe77514f479601a8e9535f4ec /Sources/BubombCore/Utilities/ExecutionError.swift | |
Diffstat (limited to 'Sources/BubombCore/Utilities/ExecutionError.swift')
| -rw-r--r-- | Sources/BubombCore/Utilities/ExecutionError.swift | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/Sources/BubombCore/Utilities/ExecutionError.swift b/Sources/BubombCore/Utilities/ExecutionError.swift new file mode 100644 index 0000000..ea2fd5f --- /dev/null +++ b/Sources/BubombCore/Utilities/ExecutionError.swift @@ -0,0 +1,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)" + } + } +} |
