Skip to content

Commit

Permalink
Refactoring BuildError
Browse files Browse the repository at this point in the history
  • Loading branch information
swiftyfinch committed Feb 26, 2024
1 parent ca86ef0 commit 6650943
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions Sources/RugbyFoundation/Core/Build/BuildError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,20 @@ enum BuildError: LocalizedError, Equatable {
switch self {
case let .buildFailed(errors, buildLogPath, rawBuildLogPath):
return """
\("Build failed.".red)
\("Xcodebuild failed.".red)
\(errors.map(formatBuildError).joined(separator: "\n").white)
\("🚑 More information in build logs:".yellow)
\("[Beautified]".yellow) \("cat \(buildLogPath.homeFinderRelativePath())".white)
\("[Raw]".yellow) \("open \(rawBuildLogPath.homeFinderRelativePath())".white)
\("[Beautified]".yellow) \("cat \(buildLogPath.homeFinderRelativePath())".white.applyingStyle(.default))
\("[Raw]".yellow) \("open \(rawBuildLogPath.homeFinderRelativePath())".white.applyingStyle(.default))
"""
case .cantFindBuildTargets:
return "Couldn't find any build targets."
}
}

private func formatBuildError(_ errorText: String) -> String {
"\("\u{2716}\u{0000FE0E}".red) \(errorText)"
let errorText = errorText.raw.hasPrefix("") ? errorText : "\("".red) \(errorText)"
return errorText
.components(separatedBy: "\n")
.map { " \($0)" }
.joined(separator: "\n")
Expand Down

0 comments on commit 6650943

Please sign in to comment.