35 lines
1.1 KiB
Go
35 lines
1.1 KiB
Go
package notice
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
)
|
|
|
|
var (
|
|
ErrUnsupportedChannel = errors.New("notice: unsupported channel")
|
|
ErrChannelNotConfigured = errors.New("notice: channel not configured")
|
|
ErrInvalidConfig = errors.New("notice: invalid config")
|
|
ErrInvalidMessage = errors.New("notice: invalid message")
|
|
ErrInvalidZapConfig = errors.New("notice: invalid zap config")
|
|
)
|
|
|
|
type HTTPError struct {
|
|
Channel Channel `json:"channel" dc:"消息渠道"`
|
|
StatusCode int `json:"status_code" dc:"HTTP 响应状态码"`
|
|
Body string `json:"body,omitempty" dc:"HTTP 响应正文"`
|
|
}
|
|
|
|
func (e *HTTPError) Error() string {
|
|
return fmt.Sprintf("notice: %s webhook returned HTTP %d", e.Channel, e.StatusCode)
|
|
}
|
|
|
|
type PlatformError struct {
|
|
Channel Channel `json:"channel" dc:"消息渠道"`
|
|
Code string `json:"code" dc:"平台业务错误码"`
|
|
Message string `json:"message" dc:"平台业务错误信息"`
|
|
}
|
|
|
|
func (e *PlatformError) Error() string {
|
|
return fmt.Sprintf("notice: %s webhook failed: code=%s message=%s", e.Channel, e.Code, e.Message)
|
|
}
|