Skip to content

Commit ff59c49

Browse files
authored
Rkeithhill/fix breakpoint on nonexisting file (PowerShell#581)
* Fix bkpt set issue with network location going away * Missed UnauthorizedAccessException * Kick another build
1 parent 0ed5431 commit ff59c49

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/PowerShellEditorServices.Protocol/Server/DebugAdapter.cs

+13-6
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
using System.IO;
1616
using System.Linq;
1717
using System.Management.Automation;
18+
using System.Security;
1819
using System.Text;
1920
using System.Threading.Tasks;
2021

@@ -497,14 +498,20 @@ protected async Task HandleSetBreakpointsRequest(
497498
scriptFile = editorSession.Workspace.GetFile(setBreakpointsParams.Source.Path);
498499
}
499500
}
500-
catch (Exception e) when (e is FileNotFoundException || e is DirectoryNotFoundException)
501+
catch (Exception e) when (
502+
e is FileNotFoundException ||
503+
e is DirectoryNotFoundException ||
504+
e is IOException ||
505+
e is NotSupportedException ||
506+
e is PathTooLongException ||
507+
e is SecurityException ||
508+
e is UnauthorizedAccessException)
501509
{
502-
Logger.Write(
503-
LogLevel.Warning,
504-
$"Attempted to set breakpoints on a non-existing file: {setBreakpointsParams.Source.Path}");
505-
506-
string message = this.noDebug ? string.Empty : "Source does not exist, breakpoint not set.";
510+
Logger.WriteException(
511+
$"Failed to set breakpoint on file: {setBreakpointsParams.Source.Path}",
512+
e);
507513

514+
string message = this.noDebug ? string.Empty : "Source file could not be accessed, breakpoint not set - " + e.Message;
508515
var srcBreakpoints = setBreakpointsParams.Breakpoints
509516
.Select(srcBkpt => Protocol.DebugAdapter.Breakpoint.Create(
510517
srcBkpt, setBreakpointsParams.Source.Path, message, verified: this.noDebug));

0 commit comments

Comments
 (0)