Skip to content

Commit fbc1c17

Browse files
authored
Add Warning Message (#102)
Now gives the user an informational warning message if they try to delete a run that doesn't exist
1 parent 6275477 commit fbc1c17

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

Cli/Program.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -218,15 +218,15 @@ static void Main(string[] args)
218218
(MonitorCommandOptions opts) => RunMonitorCommand(opts),
219219
(ExportCollectCommandOptions opts) => RunExportCollectCommand(opts),
220220
(ExportMonitorCommandOptions opts) => RunExportMonitorCommand(opts),
221-
(ConfigCommandOptions opts) => SetupConfig(opts),
221+
(ConfigCommandOptions opts) => RunConfigCommand(opts),
222222
errs => 1
223223
);
224224

225225
Log.Information("Attack Surface Analyzer Complete.");
226226
Log.CloseAndFlush();
227227
}
228228

229-
private static int SetupConfig(ConfigCommandOptions opts)
229+
private static int RunConfigCommand(ConfigCommandOptions opts)
230230
{
231231
DatabaseManager.SqliteFilename = opts.DatabaseFilename;
232232

@@ -982,9 +982,9 @@ public static ERRORS RunGuiMonitorCommand(MonitorCommandOptions opts)
982982
FileSystemMonitor newMon = new FileSystemMonitor(opts.RunId, dir, opts.InterrogateChanges);
983983
monitors.Add(newMon);
984984
}
985-
catch (ArgumentException e)
985+
catch (ArgumentException)
986986
{
987-
Log.Information("{0} is an invalid path.",dir);
987+
Log.Warning("{0} is an invalid path.",dir);
988988
return ERRORS.INVALID_PATH;
989989
}
990990
}

Lib/Utils/DatabaseManager.cs

+5
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,11 @@ public static void DeleteRun(string runid)
279279
cmd.Parameters.AddWithValue("@run_id", runid);
280280
using (var reader = cmd.ExecuteReader())
281281
{
282+
if (!reader.HasRows)
283+
{
284+
Log.Warning("That Run ID wasn't found in the database");
285+
return;
286+
}
282287
while (reader.Read())
283288
{
284289
using (var inner_cmd = new SqliteCommand(SQL_TRUNCATE_RUN, DatabaseManager.Connection, DatabaseManager.Transaction))

0 commit comments

Comments
 (0)