Skip to content

Instantly share code, notes, and snippets.

@kostrse
Created December 1, 2016 09:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kostrse/b3e923c288f66b1dc72c6702975f665f to your computer and use it in GitHub Desktop.
Save kostrse/b3e923c288f66b1dc72c6702975f665f to your computer and use it in GitHub Desktop.
static async Task FailsAsync(bool shouldFail)
{
if (shouldFail)
throw new ApplicationException("Custom exception.");
await Task.CompletedTask;
}
static Task Fails(bool shouldFail)
{
if (shouldFail)
throw new ApplicationException("Custom exception.");
return Task.CompletedTask;
}
static void Main(string[] args)
{
try
{
var t = FailsAsync(true);
//var t = Fails(true);
Console.WriteLine("FailsAsync() doesn't fail here.");
}
catch (Exception ex)
{
Console.WriteLine("Fails() fails here.");
Console.WriteLine(ex.ToString());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment