forked from open-policy-agent/opa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
errors.go
32 lines (25 loc) · 899 Bytes
/
errors.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Copyright 2021 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 errors contains reusable error-related code for the storage layer.
package errors
import (
"fmt"
"github.com/meta-quick/opax/storage"
)
const ArrayIndexTypeMsg = "array index must be integer"
const DoesNotExistMsg = "document does not exist"
const OutOfRangeMsg = "array index out of range"
func NewNotFoundError(path storage.Path) *storage.Error {
return NewNotFoundErrorWithHint(path, DoesNotExistMsg)
}
func NewNotFoundErrorWithHint(path storage.Path, hint string) *storage.Error {
return NewNotFoundErrorf("%v: %v", path.String(), hint)
}
func NewNotFoundErrorf(f string, a ...interface{}) *storage.Error {
msg := fmt.Sprintf(f, a...)
return &storage.Error{
Code: storage.NotFoundErr,
Message: msg,
}
}