Skip to content

GetEditorContext throws NullReferenceException when not supported #610

Open
@SeeminglyScience

Description

@SeeminglyScience

$psEditor.GetEditorContext currently throws a AggregateException wrapping a NullReferenceException when not supported by the editor. It should throw a NotSupportedException instead.

In Atom:

$psEditor.GetEditorContext()
# Exception calling "GetEditorContext" with "0" argument(s): "One or more errors occurred."
# At line:1 char:1
# + $psEditor.GetEditorContext()
# + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#     + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
#     + FullyQualifiedErrorId : AggregateException
 
$Error[0].Exception.GetBaseException() | Format-List * -Force
# Message        : Object reference not set to an instance of an object.
# Data           : {}
# InnerException : 
# TargetSite     : Microsoft.PowerShell.EditorServices.Extensions.EditorContext 
#                  ConvertClientEditorContext(Microsoft.PowerShell.EditorServices.Protocol.LanguageServer.ClientEditorContext)
# StackTrace     :    at Microsoft.PowerShell.EditorServices.Protocol.Server.LanguageServerEditorOperations.ConvertClientEditorContext(ClientEditorContext 
#                  clientContext)
#                     at Microsoft.PowerShell.EditorServices.Protocol.Server.LanguageServerEditorOperations.<GetEditorContext>d__3.MoveNext()
# HelpLink       : 
# Source         : Microsoft.PowerShell.EditorServices.Protocol
# HResult        : -2147467261

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions