Skip to content

Rkeithhill/fix breakpoint on nonexisting file #581

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 5, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions src/PowerShellEditorServices.Protocol/Server/DebugAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using System.IO;
using System.Linq;
using System.Management.Automation;
using System.Security;
using System.Text;
using System.Threading.Tasks;

Expand Down Expand Up @@ -497,14 +498,20 @@ protected async Task HandleSetBreakpointsRequest(
scriptFile = editorSession.Workspace.GetFile(setBreakpointsParams.Source.Path);
}
}
catch (Exception e) when (e is FileNotFoundException || e is DirectoryNotFoundException)
catch (Exception e) when (
e is FileNotFoundException ||
e is DirectoryNotFoundException ||
e is IOException ||
e is NotSupportedException ||
e is PathTooLongException ||
e is SecurityException ||
e is UnauthorizedAccessException)
{
Logger.Write(
LogLevel.Warning,
$"Attempted to set breakpoints on a non-existing file: {setBreakpointsParams.Source.Path}");

string message = this.noDebug ? string.Empty : "Source does not exist, breakpoint not set.";
Logger.WriteException(
$"Failed to set breakpoint on file: {setBreakpointsParams.Source.Path}",
e);

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