package errors import ( "errors" "fmt" ) var ( ErrInvalidConfig = errors.New("invalid configuration") ErrLoginFailed = errors.New("login failed") ErrCaptchaFailed = errors.New("captcha recognition failed") ErrScheduleFailed = errors.New("failed to fetch schedule") ErrRecognitionFailed = errors.New("schedule recognition failed") ErrUnauthorized = errors.New("unauthorized access") ErrTimeout = errors.New("operation timeout") ErrConnectionFailed = errors.New("connection failed") ) type ScheduleError struct { Op string Err error Msg string } func (e *ScheduleError) Error() string { if e.Msg != "" { return fmt.Sprintf("%s: %s: %v", e.Op, e.Msg, e.Err) } return fmt.Sprintf("%s: %v", e.Op, e.Err) } func (e *ScheduleError) Unwrap() error { return e.Err } func New(op string, err error, msg string) error { return &ScheduleError{ Op: op, Err: err, Msg: msg, } } func Wrap(err error, msg string) error { return fmt.Errorf("%s: %w", msg, err) } func Join(errs ...error) error { return errors.Join(errs...) } func Is(err, target error) bool { return errors.Is(err, target) } func As(err error, target any) bool { return errors.As(err, target) }