Skip to content

Commit

Permalink
Log exception msg and stack trace (#42)
Browse files Browse the repository at this point in the history
* Log exception msg and stack trace

* Bump SDK version due to CA issues
  • Loading branch information
stevejgordon committed Jul 4, 2022
1 parent 2283072 commit e0d366b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
git tag --list
- uses: actions/setup-dotnet@v1
with:
dotnet-version: '5.0.100'
dotnet-version: '5.0.408'
source-url: https://nuget.pkg.github.com/elastic/index.json
env:
NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "5.0.100",
"version": "5.0.408",
"rollForward": "latestFeature",
"allowPrerelease": false
}
Expand Down
14 changes: 8 additions & 6 deletions src/Elastic.Elasticsearch.Ephemeral/EphemeralClusterComposer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using Elastic.Elasticsearch.Ephemeral.Tasks.InstallationTasks.XPack;
using Elastic.Elasticsearch.Ephemeral.Tasks.ValidationTasks;
using Elastic.Elasticsearch.Managed.FileSystem;
using Elastic.Elasticsearch.Managed.ConsoleWriters;

namespace Elastic.Elasticsearch.Ephemeral
{
Expand Down Expand Up @@ -73,9 +74,9 @@ public class EphemeralClusterComposer<TConfiguration> : EphemeralClusterComposer

private bool NodeStarted { get; set; }

public void OnStop() => Itterate(NodeStoppedTasks, (t, c, fs) => t.Run(c, NodeStarted), false);
public void OnStop() => Iterate(NodeStoppedTasks, (t, c, fs) => t.Run(c, NodeStarted), false);

public void Install() => Itterate(InstallationTasks, (t, c, fs) => t.Run(c));
public void Install() => Iterate(InstallationTasks, (t, c, fs) => t.Run(c));

public void OnBeforeStart()
{
Expand All @@ -86,7 +87,7 @@ public void OnBeforeStart()
if (Cluster.ClusterConfiguration.PrintYamlFilesInConfigFolder)
tasks.Add(new PrintYamlContents());

Itterate(tasks, (t, c, fs) => t.Run(c));
Iterate(tasks, (t, c, fs) => t.Run(c));

NodeStarted = true;
}
Expand All @@ -97,10 +98,10 @@ public void OnAfterStart()
var tasks = new List<IClusterComposeTask>(AfterStartedTasks);
if (Cluster.ClusterConfiguration.AdditionalAfterStartedTasks != null)
tasks.AddRange(Cluster.ClusterConfiguration.AdditionalAfterStartedTasks);
Itterate(tasks, (t, c, fs) => t.Run(c), false);
Iterate(tasks, (t, c, fs) => t.Run(c), false);
}

private void Itterate<T>(IEnumerable<T> collection,
private void Iterate<T>(IEnumerable<T> collection,
Action<T, IEphemeralCluster<TConfiguration>, INodeFileSystem> act, bool callOnStop = true)
{
lock (_lock)
Expand All @@ -111,9 +112,10 @@ private void Itterate<T>(IEnumerable<T> collection,
{
act(task, cluster, cluster.FileSystem);
}
catch (Exception)
catch (Exception ex)
{
if (callOnStop) OnStop();
cluster.Writer.WriteError($"{ex.Message}{Environment.NewLine}{ex.StackTrace}");
throw;
}
}
Expand Down

0 comments on commit e0d366b

Please sign in to comment.