oauth2/server/error.go

21 lines
412 B
Go
Raw Normal View History

2024-10-09 00:33:23 +00:00
package server
import (
2024-10-09 01:24:55 +00:00
"encoding/json"
2024-10-09 00:33:23 +00:00
2024-10-09 05:07:57 +00:00
"somehole.com/service/router"
2024-10-09 00:33:23 +00:00
)
2024-10-09 05:07:57 +00:00
type ErrorHandler struct {
router.DefaultError
2024-10-09 00:33:23 +00:00
}
2024-10-09 05:07:57 +00:00
func (*ErrorHandler) ErrorResponse(errorResponse router.ErrorResponse) router.ErrorResponse {
return &ErrorHandler{errorResponse.(router.DefaultError)}
2024-10-09 00:33:23 +00:00
}
2024-10-09 05:07:57 +00:00
func (e *ErrorHandler) BodyBytes() (body []byte) {
2024-10-09 01:24:55 +00:00
body, _ = json.Marshal(struct{ Error string }{Error: e.String()})
return
2024-10-09 00:33:23 +00:00
}