Commit 5a20d08d6546fa260cd5ce2ed01e438f5ec35f41

Omar Polo 2022-02-09T14:59:46

tweak error reporting due to invalid numbers Use the same idiom as in the strtonum(3) manpage which produces a more readable error message. OK kn, stsp

diff --git a/got/got.c b/got/got.c
index 03281c0..23e3b35 100644
--- a/got/got.c
+++ b/got/got.c
@@ -4110,12 +4110,14 @@ cmd_log(int argc, char *argv[])
 			diff_context = strtonum(optarg, 0, GOT_DIFF_MAX_CONTEXT,
 			    &errstr);
 			if (errstr != NULL)
-				err(1, "-C option %s", errstr);
+				errx(1, "number of context lines is %s: %s",
+				    errstr, optarg);
 			break;
 		case 'l':
 			limit = strtonum(optarg, 0, INT_MAX, &errstr);
 			if (errstr != NULL)
-				err(1, "-l option %s", errstr);
+				errx(1, "number of commits is %s: %s",
+				    errstr, optarg);
 			break;
 		case 'b':
 			log_branches = 1;
@@ -4530,7 +4532,8 @@ cmd_diff(int argc, char *argv[])
 			diff_context = strtonum(optarg, 0, GOT_DIFF_MAX_CONTEXT,
 			    &errstr);
 			if (errstr != NULL)
-				err(1, "-C option %s", errstr);
+				errx(1, "number of context lines is %s: %s",
+				    errstr, optarg);
 			break;
 		case 'r':
 			repo_path = realpath(optarg, NULL);
diff --git a/tog/tog.c b/tog/tog.c
index 982154f..280413b 100644
--- a/tog/tog.c
+++ b/tog/tog.c
@@ -3884,7 +3884,8 @@ cmd_diff(int argc, char *argv[])
 			diff_context = strtonum(optarg, 0, GOT_DIFF_MAX_CONTEXT,
 			    &errstr);
 			if (errstr != NULL)
-				err(1, "-C option %s", errstr);
+				errx(1, "number of context lines is %s: %s",
+				    errstr, errstr);
 			break;
 		case 'r':
 			repo_path = realpath(optarg, NULL);