MCPcopy Index your code
hub / github.com/getsops/sops / formatError

Function formatError

age/keysource.go:217–239  ·  view source on GitHub ↗
(msg string, err error, errs errSet, unusedLocations []string)

Source from the content-addressed store, hash-verified

215}
216
217func formatError(msg string, err error, errs errSet, unusedLocations []string) error {
218 var loadSuffix string
219 if len(errs) > 0 {
220 loadSuffix = fmt.Sprintf(". Errors while loading age identities: %s", errs.Error())
221 }
222 var unusedSuffix string
223 if len(unusedLocations) > 0 {
224 count := len(unusedLocations)
225 if count == 1 {
226 unusedSuffix = fmt.Sprintf(" '%s'", unusedLocations[0])
227 } else if count == 2 {
228 unusedSuffix = fmt.Sprintf("s '%s' and '%s'", unusedLocations[0], unusedLocations[1])
229 } else {
230 unusedSuffix = fmt.Sprintf("s '%s', and '%s'", strings.Join(unusedLocations[:count-1], "', '"), unusedLocations[count-1])
231 }
232 unusedSuffix = fmt.Sprintf(". Did not find keys in location%s.", unusedSuffix)
233 }
234 if err != nil {
235 return fmt.Errorf("%s: %w%s%s", msg, err, loadSuffix, unusedSuffix)
236 } else {
237 return fmt.Errorf("%s%s%s", msg, loadSuffix, unusedSuffix)
238 }
239}
240
241// Decrypt decrypts the EncryptedKey with the parsed or loaded identities, and
242// returns the result.

Callers 1

DecryptMethod · 0.85

Calls 1

ErrorMethod · 0.45

Tested by

no test coverage detected