WIP: Full restruct, seprate service and api

Signed-off-by: Asai Neko <sugar@sne.moe>
This commit is contained in:
2026-01-24 11:42:35 +08:00
parent dfd5532b20
commit 8e11ba4631
31 changed files with 830 additions and 248 deletions

View File

@@ -13,12 +13,13 @@ import (
// :5=original
type Builder struct {
Status string
Service string
Endpoint string
Type string
Original string
Error error
Status string
Service string
Endpoint string
Type string
Original string
Error error
ErrorCode string
}
func (self *Builder) SetStatus(s string) *Builder {
@@ -51,16 +52,25 @@ func (self *Builder) SetError(e error) *Builder {
return self
}
func (self *Builder) Build(ctx context.Context) string {
errorCode := fmt.Sprintf("%s%s%s%s%s",
func (self *Builder) build() {
self.ErrorCode = fmt.Sprintf("%s%s%s%s%s",
self.Status,
self.Service,
self.Endpoint,
self.Type,
self.Original,
)
if self.Error != nil {
ErrorHandler(ctx, self.Status, errorCode, self.Error)
}
return errorCode
}
func (self *Builder) Throw(ctx *context.Context) *Builder {
self.build()
if self.Error != nil {
ErrorHandler(ctx, self.Status, self.ErrorCode, self.Error)
}
return self
}
func (self *Builder) String() string {
self.build()
return self.ErrorCode
}