Skip to content

Commit 0e93a01

Browse files
committed
Add custom breakpoint filters for Warning, Notice, etc.
1 parent 6ebd8be commit 0e93a01

File tree

1 file changed

+23
-11
lines changed

1 file changed

+23
-11
lines changed

src/phpDebug.ts

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,24 @@ class PhpDebugSession extends vscode.DebugSession {
129129
response.body.supportsConfigurationDoneRequest = true;
130130
response.body.supportsEvaluateForHovers = false;
131131
response.body.supportsConditionalBreakpoints = true;
132+
response.body.exceptionBreakpointFilters = [
133+
{
134+
filter: 'Notice',
135+
label: 'Notices'
136+
},
137+
{
138+
filter: 'Warning',
139+
label: 'Warnings'
140+
},
141+
{
142+
filter: 'Exception',
143+
label: 'Exceptions'
144+
},
145+
{
146+
filter: '*',
147+
label: 'Everything',
148+
}
149+
];
132150
this.sendResponse(response);
133151
}
134152

@@ -386,11 +404,6 @@ class PhpDebugSession extends vscode.DebugSession {
386404

387405
/** This is called once after all line breakpoints have been set and whenever the breakpoints settings change */
388406
protected setExceptionBreakPointsRequest(response: VSCodeDebugProtocol.SetExceptionBreakpointsResponse, args: VSCodeDebugProtocol.SetExceptionBreakpointsArguments): void {
389-
// args.filters can contain 'all' and 'uncaught', but 'uncaught' is the only setting XDebug supports
390-
const breakOnExceptions = args.filters.indexOf('uncaught') !== -1;
391-
if (args.filters.indexOf('all') !== -1) {
392-
this.sendEvent(new vscode.OutputEvent('breaking on caught exceptions is not supported by XDebug', 'stderr'));
393-
}
394407
const connections = Array.from(this._connections.values());
395408
Promise.all(connections.map(connection =>
396409
// get all breakpoints
@@ -401,12 +414,11 @@ class PhpDebugSession extends vscode.DebugSession {
401414
.filter(breakpoint => breakpoint.type === 'exception')
402415
.map(breakpoint => breakpoint.remove())
403416
))
404-
.then(() => {
405-
// if enabled, set exception breakpoint for all exceptions
406-
if (breakOnExceptions) {
407-
return connection.sendBreakpointSetCommand(new xdebug.ExceptionBreakpoint('*'));
408-
}
409-
})
417+
.then(() => Promise.all(
418+
args.filters.map(filter =>
419+
connection.sendBreakpointSetCommand(new xdebug.ExceptionBreakpoint(filter))
420+
)
421+
))
410422
)).then(() => {
411423
this.sendResponse(response);
412424
}).catch(error => {

0 commit comments

Comments
 (0)