MCPcopy Create free account
hub / github.com/conforma/cli / createValidationResultFromError

Function createValidationResultFromError

cmd/validate/vsa.go:1860–1885  ·  view source on GitHub ↗

createValidationResultFromError creates a ValidationResult from an error This ensures proper display of VSA status even when validation fails

(err error)

Source from the content-addressed store, hash-verified

1858// createValidationResultFromError creates a ValidationResult from an error
1859// This ensures proper display of VSA status even when validation fails
1860func createValidationResultFromError(err error) *vsa.ValidationResult {
1861 if err == nil {
1862 return nil
1863 }
1864
1865 // Determine reason code from error message
1866 reasonCode := retrievalFailedRC
1867 errMsg := err.Error()
1868
1869 // Check for specific error types
1870 if strings.Contains(errMsg, "timeout") || strings.Contains(errMsg, "exceeded allowed execution time") {
1871 reasonCode = retrievalFailedRC
1872 } else if strings.Contains(errMsg, "no entries found") || strings.Contains(errMsg, "not found") {
1873 reasonCode = "no_vsa"
1874 } else if strings.Contains(errMsg, "signature") {
1875 reasonCode = retrievalFailedRC
1876 }
1877
1878 return &vsa.ValidationResult{
1879 Passed: false,
1880 Message: errMsg,
1881 SignatureVerified: false, // When retrieval fails, signature cannot be verified
1882 PredicateOutcome: "",
1883 ReasonCode: reasonCode,
1884 }
1885}
1886
1887// ResultType represents the classification of a component validation result
1888type ResultType int

Callers 2

createErrorResultFunction · 0.85

Calls 1

ErrorMethod · 0.65

Tested by

no test coverage detected