code.gitea.io/gitea@v1.19.3/modules/auth/password/hash/common.go (about)

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