handleFileAnnotationSetError will attempt to handle the error as a FileAnnotationSet, and if so, print the FileAnnotationSet to the writer with the given error format while returning ErrFileAnnotation. Otherwise, the original error is returned.
(retErrAddr *error)
| 1361 | // |
| 1362 | // Otherwise, the original error is returned. |
| 1363 | func (c *controller) handleFileAnnotationSetRetError(retErrAddr *error) { |
| 1364 | if *retErrAddr == nil { |
| 1365 | return |
| 1366 | } |
| 1367 | var fileAnnotationSet bufanalysis.FileAnnotationSet |
| 1368 | if errors.As(*retErrAddr, &fileAnnotationSet) { |
| 1369 | writer := c.container.Stderr() |
| 1370 | if c.fileAnnotationsToStdout { |
| 1371 | writer = c.container.Stdout() |
| 1372 | } |
| 1373 | if err := bufanalysis.PrintFileAnnotationSet( |
| 1374 | writer, |
| 1375 | fileAnnotationSet, |
| 1376 | c.fileAnnotationErrorFormat, |
| 1377 | ); err != nil { |
| 1378 | *retErrAddr = err |
| 1379 | return |
| 1380 | } |
| 1381 | *retErrAddr = ErrFileAnnotation |
| 1382 | } |
| 1383 | } |
| 1384 | |
| 1385 | // Implements [protoyaml.Validator] using [protovalidate.Validator]. This allows us to pass |
| 1386 | // a [protovalidate.Validator] to the [protoencoding.NewYAMLUnmarshaler] and validate types |
no test coverage detected