Unify fallback and unimplemented API error handling

- Add a shared common error response schema and unknown error code for business-level fallbacks
- Return business error payloads for router NoRoute and NoMethod fallbacks
- Align the existing event list fallback response with the shared error structure
- Introduce an explicit unimplemented API error type instead of relying on formatted strings
- Make /api batch dispatch return per-item status 600 error entries for unimplemented modules and actions without failing the whole batch

Signed-off-by: Sean Du <do4suki@gmail.com>
This commit is contained in:
2026-06-06 17:13:27 +08:00
parent f6466989c6
commit 0dd5df0302
35 changed files with 149 additions and 72 deletions
+5 -13
View File
@@ -1,11 +1,12 @@
package event
import (
"honoka-chan/internal/constant"
"honoka-chan/internal/middleware"
"honoka-chan/internal/router"
commonschema "honoka-chan/internal/schema/common"
eventschema "honoka-chan/internal/schema/event"
"honoka-chan/internal/session"
"time"
"github.com/gin-gonic/gin"
)
@@ -22,21 +23,12 @@ func list(ctx *gin.Context) {
})
}
// ss.Respond(event.ListResp{
// ResponseData: map[string]int{
// "error_code": 10004,
// },
// ReleaseInfo: []any{},
// StatusCode: 600,
// })
ss.Respond(eventschema.ListResp{
ResponseData: eventschema.ListData{
TargetList: targets,
ServerTimestamp: time.Now().Unix(),
ResponseData: commonschema.ErrorData{
ErrorCode: constant.ErrorCodeEventNoEventData,
},
ReleaseInfo: []any{},
StatusCode: 200,
StatusCode: 600,
})
}