Skip to content

Commit

Permalink
Make error message context optional
Browse files Browse the repository at this point in the history
  • Loading branch information
pepicrft committed Apr 16, 2024
1 parent 0c5b037 commit 2fe5348
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Sources/SwiftTerminal/Components/CompletionMessage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Foundation

public enum CompletionMessage {
public enum Message {
case error(message: String, context: String, nextSteps: [String])
case error(message: String, context: String?, nextSteps: [String])
case success(action: String)
case warnings(_ warnings: [String])
}
Expand All @@ -13,10 +13,13 @@ public enum CompletionMessage {
var content = """
\("✘ An error ocurred".hexColorIfEnabled(theme.danger).bold)
\(errorMessage.split(separator: "\n").map { " \($0)" }.joined(separator: "\n"))
"""
if let context = context {
content = """
\(" \("Context".underline)".hexColorIfEnabled(theme.danger))
\(context.split(separator: "\n").map { " \($0)" }.joined(separator: "\n"))
"""
}
if !nextSteps.isEmpty {
content = """
\(content)
Expand Down

0 comments on commit 2fe5348

Please sign in to comment.