Use eris for error management

This commit is contained in:
Jamie Curnow committed 2023-02-24 17:19:07 +10:00
1 parent 80315bd50e
commit c288886fd4
44 files changed
+173 -128

No files matched your search

+2 -2
View File
@@ -3,13 +3,13 @@ package middleware
import (
"context"
"encoding/json"
"fmt"
"net/http"
c "npm/internal/api/context"
h "npm/internal/api/http"
"github.com/qri-io/jsonschema"
"github.com/rotisserie/eris"
)
// CheckRequestSchema checks the payload against schema
@@ -17,7 +17,7 @@ func CheckRequestSchema(ctx context.Context, schemaData string, payload []byte)
// Create root schema
rs := &jsonschema.Schema{}
if err := json.Unmarshal([]byte(schemaData), rs); err != nil {
return nil, fmt.Errorf("Schema Fatal: %v", err)
return nil, eris.Wrapf(err, "Schema Fatal: %v", err)
}
// Validate it