Files
releases/storage/disk/errors.go
T
Torin Sandall 1eb0220adb storage/disk: Add new disk-based storage implementation
This commit adds library support for a disk-based storage
implementation that persists policies and data using an embedded
key-value store (badger).

Signed-off-by: Torin Sandall <torinsandall@gmail.com>
2021-08-30 16:09:54 -07:00

25 lines
710 B
Go

// 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 disk
import (
"github.com/open-policy-agent/opa/storage"
)
var errNotFound = &storage.Error{Code: storage.NotFoundErr}
func wrapError(err error) error {
if err == nil {
return nil
}
if _, ok := err.(*storage.Error); ok {
return err
}
// NOTE(tsandall): we intentionally do not convert badger.ErrKeyNotFound to
// NotFoundErr code here because the former may not always need to be
// represented as a NotFoundErr (i.e., it may depend on the call-site.)
return &storage.Error{Code: storage.InternalErr, Message: err.Error()}
}