Files
bitmagnet/internal/classifier/classification/errors.go
T
mgdigital c16f76130c Classifier rewrite (#213)
The classifier has been re-implemented and now uses a DSL allowing for full customisation. Several bugs have also been fixed.

- Closes https://github.com/bitmagnet-io/bitmagnet/issues/182
- Closes https://github.com/bitmagnet-io/bitmagnet/issues/70
- Closes https://github.com/bitmagnet-io/bitmagnet/issues/68
- Hopefully fixes https://github.com/bitmagnet-io/bitmagnet/issues/126
2024-04-21 16:24:10 +01:00

49 lines
731 B
Go

package classification
import (
"fmt"
"strings"
)
type Error interface {
error
Key() string
}
type WorkflowError struct {
key string
message string
}
func (e WorkflowError) Error() string {
if e.message != "" {
return e.message
}
return fmt.Sprintf("workflow unmarshalError: %s", e.key)
}
func (e WorkflowError) Key() string {
return e.key
}
var ErrUnmatched = WorkflowError{
key: "unmatched",
}
var ErrDeleteTorrent = WorkflowError{
key: "delete_torrent",
}
type RuntimeError struct {
Path []string
Cause error
}
func (e RuntimeError) Error() string {
return fmt.Sprintf("runtime error at Path %s: %s", strings.Join(e.Path, "."), e.Cause)
}
func (e RuntimeError) Unwrap() error {
return e.Cause
}