refactor: extract base exporter, add sentinel errors, document unused fields

This commit is contained in:
2026-09-21 09:46:39 +02:00
parent 74906ee6a3
commit defce7d2d3
12 changed files with 136 additions and 42 deletions
+3 -2
View File
@@ -6,6 +6,7 @@ import (
"context"
"fmt"
"github.com/kjanat/articulate-parser/internal/apperrors"
"github.com/kjanat/articulate-parser/internal/interfaces"
"github.com/kjanat/articulate-parser/internal/models"
)
@@ -37,7 +38,7 @@ func NewApp(parser interfaces.CourseParser, exporterFactory interfaces.ExporterF
func (a *App) ProcessCourseFromFile(ctx context.Context, filePath, format, outputPath string) error {
// Check for cancellation before loading
if err := ctx.Err(); err != nil {
return fmt.Errorf("operation canceled: %w", err)
return fmt.Errorf("%w: %w", apperrors.ErrOperationCanceled, err)
}
course, err := a.parser.LoadCourseFromFile(filePath)
@@ -68,7 +69,7 @@ func (a *App) ProcessCourseFromURI(ctx context.Context, uri, format, outputPath
func (a *App) exportCourse(ctx context.Context, course *models.Course, format, outputPath string) error {
// Check for cancellation before export
if err := ctx.Err(); err != nil {
return fmt.Errorf("operation canceled: %w", err)
return fmt.Errorf("%w: %w", apperrors.ErrOperationCanceled, err)
}
exporter, err := a.exporterFactory.CreateExporter(format)