Skip to content

Commit

Permalink
try catch
Browse files Browse the repository at this point in the history
  • Loading branch information
cijothomas committed Jul 16, 2021
1 parent fbcb7d8 commit c31273b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ public void FailedExport(Exception ex)
}
}

[NonEvent]
public void FailedShutdown(Exception ex)
{
if (this.IsEnabled(EventLevel.Error, (EventKeywords)(-1)))
{
this.FailedShutdown(ex.ToInvariantString());
}
}

[NonEvent]
public void CanceledExport(Exception ex)
{
Expand All @@ -57,5 +66,11 @@ public void CanceledExport(string exception)
{
this.WriteEvent(2, exception);
}

[Event(3, Message = "Failed to shutdown Metrics server '{0}'", Level = EventLevel.Error)]
public void FailedShutdown(string exception)
{
this.WriteEvent(3, exception);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,15 @@ private void WorkerThread()
}
finally
{
this.httpListener.Stop();
this.httpListener.Close();
try
{
this.httpListener.Stop();
this.httpListener.Close();
}
catch (Exception exFromFinally)
{
PrometheusExporterEventSource.Log.FailedShutdown(exFromFinally);
}
}
}
}
Expand Down

0 comments on commit c31273b

Please sign in to comment.