add error statement for context

This commit is contained in:
AshwiniK-protean
2025-04-23 18:06:19 +05:30
parent d86d23d43d
commit 914d6f47f2
222 changed files with 30003 additions and 1123 deletions

View File

@@ -0,0 +1,33 @@
package main
import (
"context"
"errors"
definition "github.com/beckn/beckn-onix/pkg/plugin/definition"
schemaValidator "github.com/beckn/beckn-onix/pkg/plugin/implementation/schemaValidator"
)
// schemaValidatorProvider provides instances of schemaValidator.
type schemaValidatorProvider struct{}
// New initializes a new Verifier instance.
func (vp schemaValidatorProvider) New(ctx context.Context, config map[string]string) (definition.SchemaValidator, func() error, error) {
if ctx == nil {
return nil, nil, errors.New("context cannot be nil")
}
// Extract schema_dir from the config map
schemaDir, ok := config["schema_dir"]
if !ok || schemaDir == "" {
return nil, nil, errors.New("config must contain 'schema_dir'")
}
// Create a new schemaValidator instance with the provided configuration
return schemaValidator.New(ctx, &schemaValidator.Config{
SchemaDir: schemaDir,
})
}
// Provider is the exported symbol that the plugin manager will look for.
var Provider definition.SchemaValidatorProvider = schemaValidatorProvider{}