Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

common.go 1.0KB

12345678910111213141516171819202122232425262728
  1. // Copyright 2023 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package hash
  4. import (
  5. "strconv"
  6. "code.gitea.io/gitea/modules/log"
  7. )
  8. func parseIntParam(value, param, algorithmName, config string, previousErr error) (int, error) {
  9. parsed, err := strconv.Atoi(value)
  10. if err != nil {
  11. log.Error("invalid integer for %s representation in %s hash spec %s", param, algorithmName, config)
  12. return 0, err
  13. }
  14. return parsed, previousErr // <- Keep the previous error as this function should still return an error once everything has been checked if any call failed
  15. }
  16. func parseUIntParam(value, param, algorithmName, config string, previousErr error) (uint64, error) {
  17. parsed, err := strconv.ParseUint(value, 10, 64)
  18. if err != nil {
  19. log.Error("invalid integer for %s representation in %s hash spec %s", param, algorithmName, config)
  20. return 0, err
  21. }
  22. return parsed, previousErr // <- Keep the previous error as this function should still return an error once everything has been checked if any call failed
  23. }