From 9bb7ab846f85052413d51e1cdbea8f8776950ddb Mon Sep 17 00:00:00 2001 From: jvoisin Date: Sun, 22 Oct 2017 21:24:03 +0200 Subject: Improve an error message --- src/sp_config_utils.c | 10 +++++++--- src/tests/broken_conf_invalid_cidr_value.phpt | 4 ++-- src/tests/broken_conf_line_empty_string.phpt | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/sp_config_utils.c b/src/sp_config_utils.c index b0c7d3c..f562ffd 100644 --- a/src/sp_config_utils.c +++ b/src/sp_config_utils.c @@ -107,9 +107,13 @@ static char *get_string(size_t *consumed, char *restrict line, ret[j++] = line[i]; } err: - sp_log_err("error", - "There is an issue with the parsing of '%s': it doesn't look like a valid string on line %zu.", - original_line ? original_line : "NULL", sp_line_no); + if (0 == j) { + sp_log_err("error", "A valid string as parameter is expected on line %zu.", sp_line_no); + } else { + sp_log_err("error", + "There is an issue with the parsing of '%s': it doesn't look like a valid string on line %zu.", + original_line ? original_line : "NULL", sp_line_no); +} line = NULL; return NULL; } diff --git a/src/tests/broken_conf_invalid_cidr_value.phpt b/src/tests/broken_conf_invalid_cidr_value.phpt index 876e9a0..a63df28 100644 --- a/src/tests/broken_conf_invalid_cidr_value.phpt +++ b/src/tests/broken_conf_invalid_cidr_value.phpt @@ -7,5 +7,5 @@ Broken configuration, invalid cidr value sp.configuration_file={PWD}/config/broken_conf_invalid_cidr_value.ini --FILE-- --EXPECT-- -[snuffleupagus][0.0.0.0][error][error] There is an issue with the parsing of '"': it doesn't look like a valid string on line 1. -[snuffleupagus][0.0.0.0][config][error] " doesn't contain a valid cidr on line 1. +[snuffleupagus][0.0.0.0][error][error] A valid string as parameter is expected on line 1. +[snuffleupagus][0.0.0.0][config][error] " doesn't contain a valid cidr on line 1. \ No newline at end of file diff --git a/src/tests/broken_conf_line_empty_string.phpt b/src/tests/broken_conf_line_empty_string.phpt index ba8f9ca..44f8d5e 100644 --- a/src/tests/broken_conf_line_empty_string.phpt +++ b/src/tests/broken_conf_line_empty_string.phpt @@ -6,4 +6,4 @@ Configuration line with an empty string sp.configuration_file={PWD}/config/broken_conf_line_empty_string.ini --FILE-- --EXPECT-- -[snuffleupagus][0.0.0.0][error][error] There is an issue with the parsing of '': it doesn't look like a valid string on line 1. +[snuffleupagus][0.0.0.0][error][error] A valid string as parameter is expected on line 1. -- cgit v1.3