-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
29 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
using Spectre.Console; | ||
using Sentry; | ||
using Spectre.Console; | ||
using System.CommandLine; | ||
using System.CommandLine.Invocation; | ||
using System.Diagnostics; | ||
|
@@ -27,10 +28,32 @@ static async Task<int> Main(string[] args) | |
description: "Whether to save the API results to database.") | ||
}; | ||
|
||
rootCommand.Handler = CommandHandler.Create<string, bool, bool>(RunScraper); | ||
rootCommand.Handler = CommandHandler.Create<string, bool, bool>(RunScraperWithSentryExceptionLogging); | ||
|
||
return await rootCommand.InvokeAsync(args); | ||
} | ||
|
||
// System.CommandLine has extremely annoying exception handling that means we can't do this in Main() | ||
// https://github.com/dotnet/command-line-api/issues/796 | ||
static async Task RunScraperWithSentryExceptionLogging(string slackWebhookUrl, bool useCache, bool saveToDb) | ||
{ | ||
using var sentry = SentrySdk.Init(o => | ||
{ | ||
o.Dsn = "https://[email protected]/6125607"; | ||
o.TracesSampleRate = 1.0; // Capture 100% of transactions | ||
}); | ||
|
||
try | ||
{ | ||
await RunScraper(slackWebhookUrl, useCache, saveToDb); | ||
} | ||
catch (Exception ex) | ||
{ | ||
SentrySdk.CaptureException(ex); | ||
throw; | ||
} | ||
} | ||
|
||
static async Task RunScraper(string slackWebhookUrl, bool useCache, bool saveToDb) | ||
{ | ||
MarkupLine($"[green]Welcome to RezoningScraper v{Assembly.GetExecutingAssembly().GetName().Version}[/]"); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters