Enforce error diagnostics by aborting execution#607
Conversation
|
I have a question because I'm a bit confused about what to do after the creation of the wrapper. Should we use the wrapper in place of the extensions from DiagnosticCollector? |
|
I think struct ErrorThrowingDiagnosticCollector: DiagnosticCollector {
var upstream: any DiagnosticCollector
func emit(_ diagnostic: Diagnostic) throws {
upstream.emit(diagnostic)
if diagnostic.severity == .error { throw diagnostic }
}
}And then use this collector by default, wrapping today's collector. |
It makes sense, perfect!! |
Sources/swift-openapi-generator/GenerateOptions+runGenerator.swift
Outdated
Show resolved
Hide resolved
|
@swift-server-bot test this please |
|
Ok the code looks good, would you be able to add one test that constructs the pipeline with a malformed input and ends up throwing the error? Just to verify that it's really working? |
|
Sure. |
|
@swift-server-bot test this please |
|
Got some build failures on Linux: You can fix the first one by using |
|
@swift-server-bot test this please |
You'll need to add the file to the license check ignore list. |
|
Hmm this actually breaks 5.9.0, because it creates a dependency of a test target on an executable target. https://ci.swiftserver.group/job/swift-openapi-generator-swift590-prb/246/console To fix this, you'll need to start depending on I don't think we'll be able to make the new dependency work otherwise. |
Sources/swift-openapi-generator/GenerateOptions+runGenerator.swift
Outdated
Show resolved
Hide resolved
|
@swift-server-bot test this please |
|
@swift-server-bot test this please |
|
@swift-server-bot test this please |
|
@PARAIPAN9 The CI is happy, but I believe we still need to move the remaining diagnostic collection code into the new |
czechboy0
left a comment
There was a problem hiding this comment.
Thank you @PARAIPAN9, looks great now!
Motivation
Modifications
ErrorThrowingDiagnosticCollectorwrapper collector.Result
ErrorThrowingDiagnosticCollectorthrows an error when a diagnostic with severity.erroris emited.Test Plan