Files
opencloud/vendor/github.com/open-policy-agent/opa/loader/errors.go
dependabot[bot] 4d155475fe chore(deps): bump github.com/open-policy-agent/opa from 0.65.0 to 0.67.1
Bumps [github.com/open-policy-agent/opa](https://github.com/open-policy-agent/opa) from 0.65.0 to 0.67.1.
- [Release notes](https://github.com/open-policy-agent/opa/releases)
- [Changelog](https://github.com/open-policy-agent/opa/blob/main/CHANGELOG.md)
- [Commits](https://github.com/open-policy-agent/opa/compare/v0.65.0...v0.67.1)

---
updated-dependencies:
- dependency-name: github.com/open-policy-agent/opa
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-08-12 10:46:33 +02:00

63 lines
1.3 KiB
Go

// Copyright 2017 The OPA Authors. All rights reserved.
// Use of this source code is governed by an Apache2
// license that can be found in the LICENSE file.
package loader
import (
"fmt"
"strings"
"github.com/open-policy-agent/opa/ast"
)
// Errors is a wrapper for multiple loader errors.
type Errors []error
func (e Errors) Error() string {
if len(e) == 0 {
return "no error(s)"
}
if len(e) == 1 {
return "1 error occurred during loading: " + e[0].Error()
}
buf := make([]string, len(e))
for i := range buf {
buf[i] = e[i].Error()
}
return fmt.Sprintf("%v errors occurred during loading:\n", len(e)) + strings.Join(buf, "\n")
}
func (e *Errors) add(err error) {
if errs, ok := err.(ast.Errors); ok {
for i := range errs {
*e = append(*e, errs[i])
}
} else {
*e = append(*e, err)
}
}
type unsupportedDocumentType string
func (path unsupportedDocumentType) Error() string {
return string(path) + ": document must be of type object"
}
type unrecognizedFile string
func (path unrecognizedFile) Error() string {
return string(path) + ": can't recognize file type"
}
func isUnrecognizedFile(err error) bool {
_, ok := err.(unrecognizedFile)
return ok
}
type mergeError string
func (e mergeError) Error() string {
return string(e) + ": merge error"
}