Files
schedule_converter/pkg/errors/errors.go
lafay ab37aeb2fc
All checks were successful
Build / build (push) Successful in 2m17s
refactor: introduce service layer and migrate gRPC handlers to use it
Extract business logic from gRPC handlers into a dedicated service package.
Add context support throughout for cancellation and timeouts. Move models to
their own package, remove hardcoded credentials from config, and simplify
parsers to only handle HTML parsing.
2026-06-16 18:33:13 +08:00

35 lines
590 B
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package errors
import (
"errors"
"fmt"
)
var ErrLoginFailed = errors.New("login failed")
// AppError 携带操作名Op与中文提示Msg的错误类型用于统一日志与错误上报。
type AppError struct {
Op string
Err error
Msg string
}
func (e *AppError) 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 *AppError) Unwrap() error {
return e.Err
}
func New(op string, err error, msg string) error {
return &AppError{
Op: op,
Err: err,
Msg: msg,
}
}