thehrz 0b880bece8
All checks were successful
CI / deploy (push) Successful in 57s
pref: rename project
2025-01-24 17:12:15 +08:00

24 lines
503 B
Go

package yggdrasil
import (
"context"
"encoding/json"
"net/http"
"tinyskin/model/yggdrasil"
)
func handleYgError(ctx context.Context, w http.ResponseWriter, e yggdrasil.Error, httpcode int) {
w.WriteHeader(httpcode)
b, err := json.Marshal(e)
if err != nil {
panic(err)
}
w.Write(b)
}
func (y *Yggdrasil) handleYgError(ctx context.Context, w http.ResponseWriter, err error) {
y.logger.WarnContext(ctx, err.Error())
handleYgError(ctx, w, yggdrasil.Error{ErrorMessage: err.Error()}, 500)
}