mirror of
https://github.com/bitmagnet-io/bitmagnet.git
synced 2026-07-30 16:03:43 -04:00
50 lines
724 B
Go
50 lines
724 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 failed: %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
|
|
}
|