You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

errors.go 1.3 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. Copyright (c) [2023] [pcm]
  3. [pcm-coordinator] is licensed under Mulan PSL v2.
  4. You can use this software according to the terms and conditions of the Mulan PSL v2.
  5. You may obtain a copy of Mulan PSL v2 at:
  6. http://license.coscl.org.cn/MulanPSL2
  7. THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
  8. EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
  9. MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
  10. See the Mulan PSL v2 for more details.
  11. */
  12. package xerr
  13. import (
  14. "fmt"
  15. )
  16. /**
  17. 常用通用固定错误
  18. */
  19. type CodeError struct {
  20. errCode uint32
  21. errMsg string
  22. }
  23. // 返回给前端的错误码
  24. func (e *CodeError) GetErrCode() uint32 {
  25. return e.errCode
  26. }
  27. // 返回给前端显示端错误信息
  28. func (e *CodeError) GetErrMsg() string {
  29. return e.errMsg
  30. }
  31. func (e *CodeError) Error() string {
  32. return fmt.Sprintf("ErrCode:%d,ErrMsg:%s", e.errCode, e.errMsg)
  33. }
  34. func NewErrCodeMsg(errCode uint32, errMsg string) *CodeError {
  35. return &CodeError{errCode: errCode, errMsg: errMsg}
  36. }
  37. func NewErrCode(errCode uint32) *CodeError {
  38. return &CodeError{errCode: errCode, errMsg: MapErrMsg(errCode)}
  39. }
  40. func NewErrMsg(errMsg string) *CodeError {
  41. return &CodeError{errCode: SERVER_COMMON_ERROR, errMsg: errMsg}
  42. }

PCM is positioned as Software stack over Cloud, aiming to build the standards and ecology of heterogeneous cloud collaboration for JCC in a non intrusive and autonomous peer-to-peer manner.