enbas/internal/executor/executor.go
Dan Anglin c6c711c29b
fix: update error handling
Changes:

- Move InvalidListRepliesPolicyError, InvalidTimelineCategory,
  InvalidStatusVisibility and InvalidStatusContentTypeError type to the
  model package.
- Clean up some code in regards to the parsing of the Enum types.
- Clean up the error messages sent back to the user.
- Use colons instead of semicolons when unwrapping error messages.
- Print errors to Standard Error (os.Stderr)
2024-06-02 11:35:43 +01:00

25 lines
504 B
Go

// SPDX-FileCopyrightText: 2024 Dan Anglin <d.n.i.anglin@gmail.com>
//
// SPDX-License-Identifier: GPL-3.0-or-later
package executor
import "fmt"
type Executor interface {
Name() string
Parse(args []string) error
Execute() error
}
func Execute(executor Executor, args []string) error {
if err := executor.Parse(args); err != nil {
return fmt.Errorf("flag parsing error: %w", err)
}
if err := executor.Execute(); err != nil {
return fmt.Errorf("execution error: %w", err)
}
return nil
}