mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-11-06 05:12:10 +08:00
refactor: separate functions with error containing message and error with only stack trace.
This commit is contained in:
parent
1c29734a76
commit
1ebd4aa0d9
@ -16,6 +16,7 @@ package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
"net/http"
|
||||
@ -52,8 +53,8 @@ import (
|
||||
|
||||
func Start(config *config.GlobalConfig, port int, proPort int) error {
|
||||
if port == 0 || proPort == 0 {
|
||||
err := "port or proPort is empty:" + strconv.Itoa(port) + "," + strconv.Itoa(proPort)
|
||||
return errs.Wrap(fmt.Errorf(err))
|
||||
err := errors.New("port or proPort is empty:" + strconv.Itoa(port) + "," + strconv.Itoa(proPort))
|
||||
return errs.Wrap(err)
|
||||
}
|
||||
rdb, err := cache.NewRedis(&config.Redis)
|
||||
if err != nil {
|
||||
@ -85,7 +86,7 @@ func Start(config *config.GlobalConfig, port int, proPort int) error {
|
||||
p := ginprom.NewPrometheus("app", prommetrics.GetGinCusMetrics("Api"))
|
||||
p.SetListenAddress(fmt.Sprintf(":%d", proPort))
|
||||
if err = p.Use(router); err != nil && err != http.ErrServerClosed {
|
||||
netErr = errs.Wrap(err, fmt.Sprintf("prometheus start err: %d", proPort))
|
||||
netErr = errs.WrapMsg(err, fmt.Sprintf("prometheus start err: %d", proPort))
|
||||
netDone <- struct{}{}
|
||||
}
|
||||
}()
|
||||
@ -104,7 +105,7 @@ func Start(config *config.GlobalConfig, port int, proPort int) error {
|
||||
go func() {
|
||||
err = server.ListenAndServe()
|
||||
if err != nil && err != http.ErrServerClosed {
|
||||
netErr = errs.Wrap(err, fmt.Sprintf("api start err: %s", server.Addr))
|
||||
netErr = errs.WrapMsg(err, fmt.Sprintf("api start err: %s", server.Addr))
|
||||
netDone <- struct{}{}
|
||||
|
||||
}
|
||||
|
||||
@ -188,7 +188,7 @@ func (c *Client) handleMessage(message []byte) error {
|
||||
}
|
||||
|
||||
if binaryReq.SendID != c.UserID {
|
||||
return errs.Wrap(errors.New("exception conn userID not same to req userID"), binaryReq.String())
|
||||
return errs.WrapMsg(errors.New("exception conn userID not same to req userID"), binaryReq.String())
|
||||
}
|
||||
|
||||
ctx := mcontext.WithMustInfoCtx(
|
||||
|
||||
@ -209,7 +209,7 @@ func (ws *WsServer) Run(done chan error) error {
|
||||
case err = <-done:
|
||||
sErr := server.Shutdown(ctx)
|
||||
if sErr != nil {
|
||||
return errs.Wrap(sErr, "shutdown err")
|
||||
return errs.WrapMsg(sErr, "shutdown err")
|
||||
}
|
||||
close(shutdownDone)
|
||||
if err != nil {
|
||||
@ -463,7 +463,7 @@ func (ws *WsServer) ParseWSArgs(r *http.Request) (args *WSArgs, err error) {
|
||||
case constant.KickedToken:
|
||||
return nil, errs.ErrTokenKicked.Wrap()
|
||||
default:
|
||||
return nil, errs.ErrTokenUnknown.Wrap(fmt.Sprintf("token status is %d", v))
|
||||
return nil, errs.ErrTokenUnknown.WrapMsg(fmt.Sprintf("token status is %d", v))
|
||||
}
|
||||
} else {
|
||||
return nil, errs.ErrTokenNotExist.Wrap()
|
||||
|
||||
@ -138,7 +138,7 @@ func (m *MsgTransfer) Start(prometheusPort int, config *config.GlobalConfig) err
|
||||
http.Handle("/metrics", promhttp.HandlerFor(proreg, promhttp.HandlerOpts{Registry: proreg}))
|
||||
err := http.ListenAndServe(fmt.Sprintf(":%d", prometheusPort), nil)
|
||||
if err != nil && err != http.ErrServerClosed {
|
||||
netErr = errs.Wrap(err, fmt.Sprintf("prometheus start err: %d", prometheusPort))
|
||||
netErr = errs.WrapMsg(err, fmt.Sprintf("prometheus start err: %d", prometheusPort))
|
||||
netDone <- struct{}{}
|
||||
}
|
||||
}()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user