Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addded try catch block for mutex exception #3888

Merged
merged 1 commit into from
Aug 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 31 additions & 19 deletions Ginger/GingerCoreNET/LiteDBFolder/LiteDbConnector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,35 +71,41 @@
collection = db.GetCollection<T>(collectionName);
}
}
catch(UnauthorizedAccessException ex)
{
Reporter.ToLog(eLogLevel.ERROR, $"Access denied while trying to get collection: {collectionName}", ex);
}
catch (Exception ex)
{
Reporter.ToLog(eLogLevel.ERROR, $"Failed to Get Collection: {collectionName}", ex);
throw;
}
return collection;
}

/*
* This function is not used anywhere
* public bool DeleteCollectionItems<T>(LiteCollection<T> baseColl, Query query)

//This function is not used anywhere
//public bool DeleteCollectionItems<T>(LiteCollection<T> baseColl, Query query)
//{

Check warning on line 88 in Ginger/GingerCoreNET/LiteDBFolder/LiteDbConnector.cs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

Ginger/GingerCoreNET/LiteDBFolder/LiteDbConnector.cs#L88

Remove this commented out code.
// bool result = false;
// try
// {
// using (var db = new LiteDatabase(this.ConnectionString))
// {
// result = baseColl.Delete(query) > 0;
// }
// }
// catch (Exception ex)
// {
// Console.WriteLine("DeleteCollectionItems Error - " + ex.Message);
// }
// return result;
//}
Comment on lines +86 to +102
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider removing commented-out code.

The method DeleteCollectionItems is commented out and marked as not used. Removing unused code can help maintain a cleaner and more maintainable codebase. Confirm that this method is indeed not needed and consider removing it entirely.


public bool DeleteDocumentByLiteDbRunSet(LiteDbRunSet liteDbRunSet, eExecutedFrom executedFrom = eExecutedFrom.Run)
{
bool result = false;
bool result = true;
try
{
using (var db = new LiteDatabase(this.ConnectionString))
{
result = baseColl.Delete(query) > 0;
}
}
catch (Exception ex)
{
Console.WriteLine("DeleteCollectionItems Error - " + ex.Message);
}
return result;
}
*/ public bool DeleteDocumentByLiteDbRunSet(LiteDbRunSet liteDbRunSet, eExecutedFrom executedFrom = eExecutedFrom.Run)
{
bool result = true;
var runSetLiteColl = GetCollection<LiteDbRunSet>(NameInDb<LiteDbRunSet>());
var runnerssLiteColl = GetCollection<LiteDbRunner>(NameInDb<LiteDbRunner>());
foreach (LiteDbRunner ldbRunner in liteDbRunSet.RunnersColl)
Expand Down Expand Up @@ -133,6 +139,12 @@
{
runSetLiteColl.Delete(liteDbRunSet._id);
}
}
catch (Exception ex)
{
Reporter.ToLog(eLogLevel.ERROR, $"Failed to delete document for RunSet: {liteDbRunSet._id}", ex);
result = false;
}
return result;
}
public string NameInDb<T>()
Expand Down
Loading