error.go 760B

12345678910111213141516171819202122232425
  1. /**
  2. * Copyright (c) 2022 Yansen Zhang
  3. * wxcomponent 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 EXPRESS 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 errors
  13. import "fmt"
  14. // Error 通用错误
  15. type Error struct {
  16. Code float64 `json:"errcode"`
  17. Message string `json:"errmsg"`
  18. }
  19. func (e Error) Error() string {
  20. return fmt.Sprintf("[%d] - %s", int(e.Code), e.Message)
  21. }