File tree Expand file tree Collapse file tree 1 file changed +16
-4
lines changed
src/PowerShellEditorServices/Services/DebugAdapter Expand file tree Collapse file tree 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(
497497 bool writeResultAsOutput )
498498 {
499499 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+ }
504516
505517 // Since this method should only be getting invoked in the debugger,
506518 // 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