func SendErr(resp zerver.Response, err error) { switch err := err.(type) { case httperrs.Error: resp.ReportStatus(err.Code()) if err.Code() < int(httperrs.Server) { OnErrLog(resp.Send(KeyError, err.Error())) return } default: resp.ReportInternalServerError() } Logger.Errorln(err.Error()) }
func SendErr(resp zerver.Response, err error) { switch err := errors.Unwrap(err).(type) { case httperrs.Error: resp.ReportStatus(err.Code()) if err.Code() < int(httperrs.Server) { if err := resp.Send(KeyError, err.Error()); err != nil { Logger.Errorln(err.Error()) } return } default: resp.ReportInternalServerError() } Logger.Errorln(err.Error()) }
func (r *Recovery) Filter(req zerver.Request, resp zerver.Response, chain zerver.FilterChain) { defer func() { e := recover() if e == nil || r.NoStack { return } resp.ReportInternalServerError() buffer := bytes.NewBuffer(make([]byte, 0, r.Bufsize)) fmt.Fprint(buffer, e) buf := buffer.Bytes() runtime.Stack(buf[len(buf):cap(buf)], false) req.Logger().Errorln(unsafe2.String(buf[:cap(buf)])) }() chain(req, resp) }