Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(patch): Use String(reflecting: error) for printing errors #290

Merged
merged 3 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Plugins/BenchmarkTool/BenchmarkTool+Baselines.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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 {
Expand Down
8 changes: 4 additions & 4 deletions Plugins/BenchmarkTool/BenchmarkTool+Export.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion Plugins/BenchmarkTool/BenchmarkTool.swift
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ struct BenchmarkTool: AsyncParsableCommand {

try write(.end)
} catch {
print("Process failed: \(error)")
print("Process failed: \(String(reflecting: error))")
}

if status == 0 {
Expand Down
4 changes: 2 additions & 2 deletions Sources/Benchmark/Benchmark+ConvenienceInitializers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
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))")

Check warning on line 70 in Sources/Benchmark/Benchmark+ConvenienceInitializers.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Benchmark/Benchmark+ConvenienceInitializers.swift#L70

Added line #L70 was not covered by tests
}
}, teardown: teardown)

Expand All @@ -94,7 +94,7 @@
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))")

Check warning on line 97 in Sources/Benchmark/Benchmark+ConvenienceInitializers.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Benchmark/Benchmark+ConvenienceInitializers.swift#L97

Added line #L97 was not covered by tests
}
}, teardown: teardown)

Expand Down
4 changes: 2 additions & 2 deletions Sources/Benchmark/Benchmark.swift
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@
do {
try closure(benchmark)
} catch {
benchmark.error("Benchmark \(name) failed with \(error)")
benchmark.error("Benchmark \(name) failed with \(String(reflecting: error))")

Check warning on line 243 in Sources/Benchmark/Benchmark.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Benchmark/Benchmark.swift#L243

Added line #L243 was not covered by tests
}
}, setup: setup, teardown: teardown)
}
Expand All @@ -261,7 +261,7 @@
do {
try await closure(benchmark)
} catch {
benchmark.error("Benchmark \(name) failed with \(error)")
benchmark.error("Benchmark \(name) failed with \(String(reflecting: error))")

Check warning on line 264 in Sources/Benchmark/Benchmark.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Benchmark/Benchmark.swift#L264

Added line #L264 was not covered by tests
}
}, setup: setup, teardown: teardown)
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/Benchmark/BenchmarkRunner.swift
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@
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))"))

Check warning on line 199 in Sources/Benchmark/BenchmarkRunner.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Benchmark/BenchmarkRunner.swift#L199

Added line #L199 was not covered by tests
return
}

Expand Down
Loading