From 1506e1e151c778b41f169a1f2af51cd75afee50e Mon Sep 17 00:00:00 2001 From: MahdiBM Date: Tue, 8 Oct 2024 22:30:23 +0330 Subject: [PATCH] use `String(reflecting: error)` --- Plugins/BenchmarkTool/BenchmarkTool+Baselines.swift | 4 ++-- Plugins/BenchmarkTool/BenchmarkTool+Export.swift | 8 ++++---- .../BenchmarkTool+ReadP90AbsoluteThresholds.swift | 2 +- Plugins/BenchmarkTool/BenchmarkTool.swift | 2 +- Sources/Benchmark/Benchmark+ConvenienceInitializers.swift | 4 ++-- Sources/Benchmark/Benchmark.swift | 4 ++-- Sources/Benchmark/BenchmarkRunner.swift | 2 +- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Plugins/BenchmarkTool/BenchmarkTool+Baselines.swift b/Plugins/BenchmarkTool/BenchmarkTool+Baselines.swift index 8f9f6683..2a1abb37 100644 --- a/Plugins/BenchmarkTool/BenchmarkTool+Baselines.swift +++ b/Plugins/BenchmarkTool/BenchmarkTool+Baselines.swift @@ -223,7 +223,7 @@ extension BenchmarkTool { print("Removing baseline '\(baselineName)' for \(target)") try filemanager.removeItem(atPath: file.description) } catch { - print("Failed to remove file \(file), error \(error)") + print("Failed to remove file \(file), error \(String(reflecting: error))") print("Give benchmark plugin permissions to delete files by running with e.g.:") print("") print("swift package --allow-writing-to-package-directory benchmark baseline delete") @@ -376,7 +376,7 @@ extension BenchmarkTool { baseline = try JSONDecoder().decode(BenchmarkBaseline.self, from: Data(readBytes)) } catch { - print("Failed to open file for reading \(path) [\(error)]") + print("Failed to open file for reading \(path) [\(String(reflecting: error))]") } } } catch { diff --git a/Plugins/BenchmarkTool/BenchmarkTool+Export.swift b/Plugins/BenchmarkTool/BenchmarkTool+Export.swift index f43bac03..7cce2778 100644 --- a/Plugins/BenchmarkTool/BenchmarkTool+Export.swift +++ b/Plugins/BenchmarkTool/BenchmarkTool+Export.swift @@ -73,11 +73,11 @@ extension BenchmarkTool { _ = try fd.write(UnsafeRawBufferPointer($0)) } } catch { - print("Failed to write to file \(outputPath) [\(error)]") + print("Failed to write to file \(outputPath) [\(String(reflecting: error))]") } } } catch { - print("Failed to close fd for \(outputPath) after write [\(error)].") + print("Failed to close fd for \(outputPath) after write [\(String(reflecting: error))].") } } catch { if errno == EPERM { @@ -127,11 +127,11 @@ extension BenchmarkTool { _ = try fd.write(rawBuffer) } } catch { - print("Failed to write to file \(outputPath) [\(error)]") + print("Failed to write to file \(outputPath) [\(String(reflecting: error))]") } } } catch { - print("Failed to close fd for \(outputPath) after write [\(error)].") + print("Failed to close fd for \(outputPath) after write [\(String(reflecting: error))].") } } catch { if errno == EPERM { diff --git a/Plugins/BenchmarkTool/BenchmarkTool+ReadP90AbsoluteThresholds.swift b/Plugins/BenchmarkTool/BenchmarkTool+ReadP90AbsoluteThresholds.swift index d1c4838f..8a35627b 100644 --- a/Plugins/BenchmarkTool/BenchmarkTool+ReadP90AbsoluteThresholds.swift +++ b/Plugins/BenchmarkTool/BenchmarkTool+ReadP90AbsoluteThresholds.swift @@ -79,7 +79,7 @@ extension BenchmarkTool { } } } catch { - print("Failed to read file at \(path) [\(error)] \(Errno(rawValue: errno).description)") + print("Failed to read file at \(path) [\(String(reflecting: error))] \(Errno(rawValue: errno).description)") } } } catch { diff --git a/Plugins/BenchmarkTool/BenchmarkTool.swift b/Plugins/BenchmarkTool/BenchmarkTool.swift index ae80086f..76cab221 100644 --- a/Plugins/BenchmarkTool/BenchmarkTool.swift +++ b/Plugins/BenchmarkTool/BenchmarkTool.swift @@ -385,7 +385,7 @@ struct BenchmarkTool: AsyncParsableCommand { try write(.end) } catch { - print("Process failed: \(error)") + print("Process failed: \(String(reflecting: error))") } if status == 0 { diff --git a/Sources/Benchmark/Benchmark+ConvenienceInitializers.swift b/Sources/Benchmark/Benchmark+ConvenienceInitializers.swift index cc22efc4..00090fcb 100644 --- a/Sources/Benchmark/Benchmark+ConvenienceInitializers.swift +++ b/Sources/Benchmark/Benchmark+ConvenienceInitializers.swift @@ -67,7 +67,7 @@ public extension Benchmark { let setupResult = benchmark.setupState! as! SetupResult // swiftlint:disable:this force_cast try closure(benchmark, setupResult) } catch { - benchmark.error("Benchmark \(name) failed with \(error)") + benchmark.error("Benchmark \(name) failed with \(String(reflecting: error))") } }, teardown: teardown) @@ -94,7 +94,7 @@ public extension Benchmark { let setupResult = benchmark.setupState! as! SetupResult // swiftlint:disable:this force_cast try await closure(benchmark, setupResult) } catch { - benchmark.error("Benchmark \(name) failed with \(error)") + benchmark.error("Benchmark \(name) failed with \(String(reflecting: error))") } }, teardown: teardown) diff --git a/Sources/Benchmark/Benchmark.swift b/Sources/Benchmark/Benchmark.swift index bc00dc08..07c0cdf6 100644 --- a/Sources/Benchmark/Benchmark.swift +++ b/Sources/Benchmark/Benchmark.swift @@ -240,7 +240,7 @@ public final class Benchmark: Codable, Hashable { // swiftlint:disable:this type do { try closure(benchmark) } catch { - benchmark.error("Benchmark \(name) failed with \(error)") + benchmark.error("Benchmark \(name) failed with \(String(reflecting: error))") } }, setup: setup, teardown: teardown) } @@ -261,7 +261,7 @@ public final class Benchmark: Codable, Hashable { // swiftlint:disable:this type do { try await closure(benchmark) } catch { - benchmark.error("Benchmark \(name) failed with \(error)") + benchmark.error("Benchmark \(name) failed with \(String(reflecting: error))") } }, setup: setup, teardown: teardown) } diff --git a/Sources/Benchmark/BenchmarkRunner.swift b/Sources/Benchmark/BenchmarkRunner.swift index d6f93335..13978ca8 100644 --- a/Sources/Benchmark/BenchmarkRunner.swift +++ b/Sources/Benchmark/BenchmarkRunner.swift @@ -196,7 +196,7 @@ public struct BenchmarkRunner: AsyncParsableCommand, BenchmarkRunnerReadWrite { try await hook?() } } catch { - try channel.write(.error("Benchmark.teardown or local benchmark teardown failed: \(error)")) + try channel.write(.error("Benchmark.teardown or local benchmark teardown failed: \(String(reflecting: error))")) return }