Skip to content

Commit

Permalink
vstest.console: CommandLineOptions: preserve stacktrace on re-throw (…
Browse files Browse the repository at this point in the history
…CA2200) (#2606)

* vstest.console: CommandLineOptions: preserve stacktrace on re-throw (CA2200)
  • Loading branch information
tmds authored Jan 26, 2021
1 parent 0338fd2 commit c7fa186
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
10 changes: 3 additions & 7 deletions src/vstest.console/CommandLine/CommandLineOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -295,14 +295,10 @@ public void AddSource(string source)
// Get matching files from file pattern parser
matchingFiles = FilePatternParser.GetMatchingFiles(source);
}
catch(TestSourceException ex)
catch(TestSourceException ex) when (source.StartsWith("-") || source.StartsWith("/"))
{
if(source.StartsWith("-") || source.StartsWith("/"))
{
throw new TestSourceException(
string.Format(CultureInfo.CurrentUICulture, CommandLineResources.InvalidArgument, source));
}
throw ex;
throw new TestSourceException(
string.Format(CultureInfo.CurrentUICulture, CommandLineResources.InvalidArgument, source), ex);
}
// Add the matching files to source list
this.sources = this.sources.Union(matchingFiles).ToList();
Expand Down
12 changes: 11 additions & 1 deletion src/vstest.console/CommandLine/TestSourceException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,17 @@ public TestSourceException()
/// </summary>
/// <param name="message">Message for the exception.</param>
public TestSourceException(string message)
: base(message)
: this(message, innerException: null)
{
}

/// <summary>
/// Initializes with the message and innerException.
/// </summary>
/// <param name="message">Message for the exception.</param>
/// <param name="innerException">The exception that is the cause of the current exception, or a null reference.</param>
public TestSourceException(string message, Exception innerException)
: base(message, innerException)
{
}

Expand Down

0 comments on commit c7fa186

Please sign in to comment.