server: Wrap decision log error messages

Previously the server didn't wrap the error messages which made it
hard to determine the source of internal errors coming back from OPA
when deployed with a custom decision logger.

Fixes #1367

Signed-off-by: Torin Sandall <torinsandall@gmail.com>
This commit is contained in:
Torin Sandall
2019-08-22 12:25:01 -04:00
parent f638d624b1
commit df281fd020
2 changed files with 17 additions and 1 deletions
+1 -1
View File
@@ -2400,7 +2400,7 @@ func (l decisionLogger) Log(ctx context.Context, txn storage.Transaction, decisi
if l.logger != nil {
if err := l.logger(ctx, info); err != nil {
return err
return errors.Wrap(err, "decision_logs")
}
}
+16
View File
@@ -2780,6 +2780,22 @@ func TestDecisionLogging(t *testing.T) {
}
func TestDecisionLogErrorMessage(t *testing.T) {
f := newFixture(t)
f.server.WithDecisionLoggerWithErr(func(context.Context, *Info) error {
return fmt.Errorf("xxx")
})
if err := f.v1(http.MethodPost, "/data", "", 500, `{
"code": "internal_error",
"message": "decision_logs: xxx"
}`); err != nil {
t.Fatal(err)
}
}
func TestWatchParams(t *testing.T) {
f := newFixture(t)
r1 := newMockConn()