package chain import ( "context" "errors" "fmt" "gitoa.ru/go-4devs/templating/loader" "gitoa.ru/go-4devs/templating/render" ) var _ loader.Loader = (Loaders)(nil) type Loaders []loader.Loader func (l Loaders) Load(ctx context.Context, template render.Reference) (loader.Source, error) { for idx, load := range l { sourse, err := load.Load(ctx, template) if err == nil { return sourse, nil } if !errors.Is(err, loader.ErrNotFound) { return loader.Source{}, fmt.Errorf("chain[%d]:%w", idx, err) } } return loader.Source{}, fmt.Errorf("chains(%d):%w", len(l), loader.ErrNotFound) }