Skip to content

Commit 2aa43c1

Browse files
committed
Remove try/catch from Start-EditorServicesHost
This change removes the try/catch from Start-EditorServicesHost so that any initialization errors get written directly instead of wrapped in a less effective form of output.
1 parent 982ed12 commit 2aa43c1

File tree

1 file changed

+21
-27
lines changed

1 file changed

+21
-27
lines changed

module/PowerShellEditorServices/PowerShellEditorServices.psm1

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -63,34 +63,28 @@ function Start-EditorServicesHost {
6363
$editorServicesHost = $null
6464
$hostDetails = New-Object Microsoft.PowerShell.EditorServices.Session.HostDetails @($HostName, $HostProfileId, (New-Object System.Version @($HostVersion)))
6565

66-
try {
67-
$editorServicesHost =
68-
New-Object Microsoft.PowerShell.EditorServices.Host.EditorServicesHost @(
69-
$hostDetails,
70-
$BundledModulesPath,
71-
$EnableConsoleRepl.IsPresent,
72-
$WaitForDebugger.IsPresent,
73-
$FeatureFlags)
74-
75-
# Build the profile paths using the root paths of the current $profile variable
76-
$profilePaths = New-Object Microsoft.PowerShell.EditorServices.Session.ProfilePaths @(
77-
$hostDetails.ProfileId,
78-
[System.IO.Path]::GetDirectoryName($profile.AllUsersAllHosts),
79-
[System.IO.Path]::GetDirectoryName($profile.CurrentUserAllHosts));
80-
81-
$editorServicesHost.StartLogging($LogPath, $LogLevel);
82-
83-
if ($DebugServiceOnly.IsPresent) {
84-
$editorServicesHost.StartDebugService($DebugServicePort, $profilePaths, $false);
85-
}
86-
else {
87-
$editorServicesHost.StartLanguageService($LanguageServicePort, $profilePaths);
88-
$editorServicesHost.StartDebugService($DebugServicePort, $profilePaths, $true);
89-
}
66+
$editorServicesHost =
67+
New-Object Microsoft.PowerShell.EditorServices.Host.EditorServicesHost @(
68+
$hostDetails,
69+
$BundledModulesPath,
70+
$EnableConsoleRepl.IsPresent,
71+
$WaitForDebugger.IsPresent,
72+
$FeatureFlags)
73+
74+
# Build the profile paths using the root paths of the current $profile variable
75+
$profilePaths = New-Object Microsoft.PowerShell.EditorServices.Session.ProfilePaths @(
76+
$hostDetails.ProfileId,
77+
[System.IO.Path]::GetDirectoryName($profile.AllUsersAllHosts),
78+
[System.IO.Path]::GetDirectoryName($profile.CurrentUserAllHosts));
79+
80+
$editorServicesHost.StartLogging($LogPath, $LogLevel);
81+
82+
if ($DebugServiceOnly.IsPresent) {
83+
$editorServicesHost.StartDebugService($DebugServicePort, $profilePaths, $false);
9084
}
91-
catch {
92-
Write-Error "PowerShell Editor Services host initialization failed, terminating."
93-
Write-Error $_.Exception
85+
else {
86+
$editorServicesHost.StartLanguageService($LanguageServicePort, $profilePaths);
87+
$editorServicesHost.StartDebugService($DebugServicePort, $profilePaths, $true);
9488
}
9589

9690
return $editorServicesHost

0 commit comments

Comments
 (0)