You've already forked pgbackrest
							
							
				mirror of
				https://github.com/pgbackrest/pgbackrest.git
				synced 2025-10-30 23:37:45 +02:00 
			
		
		
		
	Fix for issue #74: More helpful message when targeting missing stanzas.
This commit is contained in:
		| @@ -285,6 +285,7 @@ use constant | ||||
|     OPTION_RULE_DEPEND_OPTION    => 'depend-option', | ||||
|     OPTION_RULE_DEPEND_LIST      => 'depend-list', | ||||
|     OPTION_RULE_DEPEND_VALUE     => 'depend-value', | ||||
|     OPTION_RULE_HINT             => 'hint', | ||||
|     OPTION_RULE_NEGATE           => 'negate', | ||||
|     OPTION_RULE_OPERATION        => 'operation', | ||||
|     OPTION_RULE_REQUIRED         => 'required', | ||||
| @@ -648,6 +649,7 @@ my %oOptionRule = | ||||
|     { | ||||
|         &OPTION_RULE_TYPE => OPTION_TYPE_STRING, | ||||
|         &OPTION_RULE_SECTION => CONFIG_SECTION_STANZA, | ||||
|         &OPTION_RULE_HINT => "Does this stanza exist?", | ||||
|         &OPTION_RULE_OPERATION => | ||||
|         { | ||||
|             &OP_ARCHIVE_GET => | ||||
| @@ -1501,7 +1503,10 @@ sub optionValid | ||||
|                 # Else check required | ||||
|                 elsif (optionRequired($strOption, $strOperation)) | ||||
|                 { | ||||
|                     confess &log(ERROR, "${strOperation} operation requires option: ${strOption}", ERROR_OPTION_REQUIRED); | ||||
|                     confess &log(ERROR, "${strOperation} operation requires option: ${strOption}" . | ||||
|                                         (defined($oOptionRule{$strOption}{&OPTION_RULE_HINT}) ? | ||||
|                                          "\nHINT: " . $oOptionRule{$strOption}{&OPTION_RULE_HINT} : ''), | ||||
|                                         ERROR_OPTION_REQUIRED); | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|   | ||||
| @@ -456,19 +456,21 @@ sub log | ||||
|     $strMessageFormat = (defined($iCode) ? "[${iCode}]: " : '') . $strMessageFormat; | ||||
|  | ||||
|     # Indent subsequent lines of the message if it has more than one line - makes the log more readable | ||||
|     $strMessageFormat =~ s/\n/\n                                    /g; | ||||
|  | ||||
|     if ($strLevel eq TRACE || $strLevel eq TEST) | ||||
|     { | ||||
|         $strMessageFormat =~ s/\n/\n                                           /g; | ||||
|         $strMessageFormat =~ s/\n/\n        /g; | ||||
|         $strMessageFormat = '        ' . $strMessageFormat; | ||||
|     } | ||||
|     elsif ($strLevel eq DEBUG) | ||||
|     { | ||||
|         $strMessageFormat =~ s/\n/\n                                       /g; | ||||
|         $strMessageFormat =~ s/\n/\n    /g; | ||||
|         $strMessageFormat = '    ' . $strMessageFormat; | ||||
|     } | ||||
|     else | ||||
|     elsif ($strLevel eq ERROR && defined($iCode)) | ||||
|     { | ||||
|         $strMessageFormat =~ s/\n/\n                                   /g; | ||||
|         $strMessageFormat =~ s/\n/\n       /g; | ||||
|     } | ||||
|  | ||||
|     # Format the message text | ||||
|   | ||||
| @@ -140,7 +140,8 @@ sub configLoadExpect | ||||
|  | ||||
|             if ($iExpectedError == ERROR_OPTION_REQUIRED) | ||||
|             { | ||||
|                 $strError = "backup operation requires option: ${strErrorParam1}"; | ||||
|                 $strError = "${strOperation} operation requires option: ${strErrorParam1}" . | ||||
|                             (defined($strErrorParam2) ? "\nHINT: ${strErrorParam2}" : ''); | ||||
|             } | ||||
|             elsif ($iExpectedError == ERROR_OPERATION_REQUIRED) | ||||
|             { | ||||
| @@ -443,7 +444,7 @@ sub BackRestTestConfig_Test | ||||
|             configLoadExpect($oOption, OP_RESTORE, ERROR_OPTION_INVALID_RANGE, '512', OPTION_BUFFER_SIZE); | ||||
|         } | ||||
|  | ||||
|         if (BackRestTestCommon_Run(++$iRun, OP_BACKUP . ' invalid option' . OPTION_RETENTION_ARCHIVE_TYPE)) | ||||
|         if (BackRestTestCommon_Run(++$iRun, OP_BACKUP . ' invalid option ' . OPTION_RETENTION_ARCHIVE_TYPE)) | ||||
|         { | ||||
|             optionSetTest($oOption, OPTION_STANZA, $strStanza); | ||||
|             optionSetTest($oOption, OPTION_DB_PATH, '/db'); | ||||
| @@ -547,6 +548,13 @@ sub BackRestTestConfig_Test | ||||
|             configLoadExpect($oOption, OP_BACKUP); | ||||
|             optionTestExpect(OPTION_COMMAND_REMOTE, dirname(abs_path($0)) . '/pg_backrest_remote.pl'); | ||||
|         } | ||||
|  | ||||
|         if (BackRestTestCommon_Run(++$iRun, OP_BACKUP . ' missing option ' . OPTION_DB_PATH)) | ||||
|         { | ||||
|             optionSetTest($oOption, OPTION_STANZA, $strStanza); | ||||
|  | ||||
|             configLoadExpect($oOption, OP_BACKUP, ERROR_OPTION_REQUIRED, OPTION_DB_PATH, 'Does this stanza exist?'); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     #------------------------------------------------------------------------------------------------------------------------------- | ||||
|   | ||||
		Reference in New Issue
	
	Block a user