File tree 1 file changed +16
-4
lines changed
src/PowerShellEditorServices/Services/DebugAdapter
1 file changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -497,10 +497,22 @@ public async Task<VariableDetails> EvaluateExpressionAsync(
497
497
bool writeResultAsOutput )
498
498
{
499
499
PSCommand command = new PSCommand ( ) . AddScript ( expressionString ) ;
500
- IReadOnlyList < PSObject > results = await _executionService . ExecutePSCommandAsync < PSObject > (
501
- command ,
502
- CancellationToken . None ,
503
- new PowerShellExecutionOptions { WriteOutputToHost = writeResultAsOutput , ThrowOnError = ! writeResultAsOutput } ) . ConfigureAwait ( false ) ;
500
+ IReadOnlyList < PSObject > results ;
501
+ try
502
+ {
503
+ results = await _executionService . ExecutePSCommandAsync < PSObject > (
504
+ command ,
505
+ CancellationToken . None ,
506
+ new PowerShellExecutionOptions { WriteOutputToHost = writeResultAsOutput , ThrowOnError = ! writeResultAsOutput } ) . ConfigureAwait ( false ) ;
507
+ }
508
+ catch ( Exception e )
509
+ {
510
+ // If a watch expression throws we want to show the exception.
511
+ // TODO: Show the exception as an expandable object.
512
+ return new VariableDetails (
513
+ expressionString ,
514
+ $ "{ e . GetType ( ) . Name } : { e . Message } ") ;
515
+ }
504
516
505
517
// Since this method should only be getting invoked in the debugger,
506
518
// we can assume that Out-String will be getting used to format results
You can’t perform that action at this time.
0 commit comments