fix: added error from error module

This commit is contained in:
mayur.popli
2025-04-03 13:35:49 +05:30
parent a2c27b4fbf
commit a955949857
5 changed files with 25 additions and 24 deletions

View File

@@ -3,6 +3,7 @@ package schemavalidator
import (
"context"
"encoding/json"
"errors"
"fmt"
"net/url"
"os"
@@ -77,12 +78,12 @@ func (v *schemaValidator) Validate(ctx context.Context, url *url.URL, data []byt
// Retrieve the schema from the cache.
schema, exists := v.schemaCache[schemaFileName]
if !exists {
return fmt.Errorf("schema not found for domain: %s", schemaFileName)
return model.NewNotFoundErr(errors.New("schema not found for domain"))
}
var jsonData any
if err := json.Unmarshal(data, &jsonData); err != nil {
return fmt.Errorf("failed to parse JSON data: %v", err)
return model.NewBadReqErr(err)
}
err = schema.Validate(jsonData)
if err != nil {