replace log.Fatal with cobra.CheckErr

This commit is contained in:
filifa
2025-08-27 21:33:44 -04:00
parent 51e1a97c43
commit 65c8ab4057
5 changed files with 14 additions and 18 deletions

View File

@@ -18,7 +18,6 @@ package cmd
import (
"fmt"
"log"
"math/big"
"github.com/spf13/cobra"
@@ -45,7 +44,7 @@ func count(tpf []string) map[string]*big.Int {
func primitiveRoot(cmd *cobra.Command, args []string) {
m, ok := new(big.Int).SetString(modulus, 10)
if !ok {
log.Fatal("invalid input " + modulus)
cobra.CheckErr("invalid input " + modulus)
}
factors := count(tpf)
@@ -55,12 +54,12 @@ func primitiveRoot(cmd *cobra.Command, args []string) {
if len(factors) == 0 {
root, err = lib.PrimitiveRoot(m)
if err != nil {
log.Fatal(err)
cobra.CheckErr(err)
}
} else {
root, err = lib.PrimitiveRootFast(m, factors)
if err != nil {
log.Fatal(err)
cobra.CheckErr(err)
}
}