@@ -14,6 +14,8 @@ public partial class frmMainUI : Form
1414 private bool AllowToRun ;
1515 private string CurrentFile ;
1616 private bool StopOnError ;
17+ private bool LogErrors ;
18+
1719 Stopwatch swTotalTime ;
1820
1921 public frmMainUI ( )
@@ -96,6 +98,7 @@ private void btnRunScript_Click(object sender, EventArgs e)
9698
9799 AllowToRun = true ;
98100 StopOnError = chkStopOnError . Checked ;
101+ LogErrors = chkLogErrors . Checked ;
99102
100103 foreach ( var item in lstFiles . Items )
101104 {
@@ -119,7 +122,7 @@ private void btnRunScript_Click(object sender, EventArgs e)
119122 break ;
120123
121124 }
122-
125+
123126 ControlScreen ( true ) ;
124127 System . Media . SystemSounds . Beep . Play ( ) ;
125128 }
@@ -305,10 +308,13 @@ private bool RunScript(string sourceScript, string connectionString, short qtyMa
305308 }
306309 catch ( Exception ex )
307310 {
308- string errormsg = "/* The error was: \n " + ex . Message + "\n */" ;
309- // Save the chuncks that could not be processed
310- File . AppendAllText ( errorFile , sb . ToString ( ) + Environment . NewLine ) ;
311- File . AppendAllText ( errorFile , errormsg + Environment . NewLine ) ;
311+ if ( LogErrors )
312+ {
313+ string errormsg = "/* The error was: \n " + ex . Message + "\n */" ;
314+ // Save the chuncks that could not be processed
315+ File . AppendAllText ( errorFile , sb . ToString ( ) + Environment . NewLine ) ;
316+ File . AppendAllText ( errorFile , errormsg + Environment . NewLine ) ;
317+ }
312318 qtyErrorLines ++ ;
313319 if ( StopOnError )
314320 AllowToRun = false ;
@@ -346,10 +352,13 @@ private bool RunScript(string sourceScript, string connectionString, short qtyMa
346352 }
347353 catch ( Exception ex )
348354 {
349- string errormsg = "/* The error was: \n " + ex . Message + "\n */" ;
350- // Save the chuncks that could not be processed
351- File . AppendAllText ( errorFile , sb . ToString ( ) + Environment . NewLine ) ;
352- File . AppendAllText ( errorFile , errormsg + Environment . NewLine ) ;
355+ if ( LogErrors )
356+ {
357+ string errormsg = "/* The error was: \n " + ex . Message + "\n */" ;
358+ // Save the chuncks that could not be processed
359+ File . AppendAllText ( errorFile , sb . ToString ( ) + Environment . NewLine ) ;
360+ File . AppendAllText ( errorFile , errormsg + Environment . NewLine ) ;
361+ }
353362 qtyErrorLines ++ ;
354363 if ( StopOnError )
355364 AllowToRun = false ;
0 commit comments