-
Notifications
You must be signed in to change notification settings - Fork 28.9k
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
Surfacing new Exception DAP in UI #22948
Changes from 4 commits
b304851
8e293fd
4444eeb
21680a0
c5ca501
e53980c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ const $ = dom.$; | |
|
||
export class ExceptionWidget extends ZoneWidget { | ||
|
||
constructor(editor: ICodeEditor, private lineNumber: number, | ||
constructor(editor: ICodeEditor, private exceptionInfo: DebugProtocol.ExceptionInfoResponse, private lineNumber: number, | ||
@IContextViewService private contextViewService: IContextViewService, | ||
@IDebugService private debugService: IDebugService | ||
) { | ||
|
@@ -33,15 +33,40 @@ export class ExceptionWidget extends ZoneWidget { | |
const fontInfo = this.editor.getConfiguration().fontInfo; | ||
this.container.style.fontSize = `${fontInfo.fontSize}px`; | ||
this.container.style.lineHeight = `${fontInfo.lineHeight}px`; | ||
|
||
let title = $('.title'); | ||
title.textContent = nls.localize('exceptionThrown', 'Exception occurred'); | ||
dom.append(container, title); | ||
|
||
const thread = this.debugService.getViewModel().focusedThread; | ||
|
||
if (thread && thread.stoppedDetails) { | ||
let title = $('.title'); | ||
let msg = $('.message'); | ||
msg.textContent = thread.stoppedDetails.text; | ||
|
||
if (this.exceptionInfo) { | ||
let conditionMessage; | ||
switch (this.exceptionInfo.body.breakMode) { | ||
case 'never': | ||
conditionMessage = nls.localize('neverException', 'User-handled exception has occurred.'); | ||
break; | ||
case 'always': | ||
conditionMessage = nls.localize('alwaysException', 'Always-breaking exception has occurred.'); | ||
break; | ||
case 'unhandled': | ||
conditionMessage = nls.localize('unhandledException', 'Unhandled exception has occurred.'); | ||
break; | ||
case 'userUnhandled': | ||
conditionMessage = nls.localize('userUnhandledException', 'User-unhandled exception has occurred.'); | ||
break; | ||
default: | ||
conditionMessage = ''; | ||
break; | ||
} | ||
|
||
title.textContent = `${conditionMessage} ${this.exceptionInfo.body.description}`; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are missing a colon here between the condition message and the description There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I remember we agreed on putting a colon there, but I did not put it explicitly and used a dot on the conditionMessage instead, because description itself contains a colon after the exception type, so that it ends up as What do you think is better? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
msg.textContent = this.exceptionInfo.body.details.stackTrace; | ||
} else { | ||
title.textContent = nls.localize('exceptionThrown', 'Exception occurred'); | ||
msg.textContent = thread.stoppedDetails.text; | ||
} | ||
|
||
dom.append(container, title); | ||
dom.append(container, msg); | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,6 +77,7 @@ export interface IExpression extends ITreeElement, IExpressionContainer { | |
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks good |
||
export interface ISession { | ||
stackTrace(args: DebugProtocol.StackTraceArguments): TPromise<DebugProtocol.StackTraceResponse>; | ||
exceptionInfo(args: DebugProtocol.ExceptionInfoArguments): TPromise<DebugProtocol.ExceptionInfoResponse>; | ||
scopes(args: DebugProtocol.ScopesArguments): TPromise<DebugProtocol.ScopesResponse>; | ||
variables(args: DebugProtocol.VariablesArguments): TPromise<DebugProtocol.VariablesResponse>; | ||
evaluate(args: DebugProtocol.EvaluateArguments): TPromise<DebugProtocol.EvaluateResponse>; | ||
|
@@ -133,6 +134,11 @@ export interface IThread extends ITreeElement { | |
*/ | ||
stoppedDetails: IRawStoppedDetails; | ||
|
||
/** | ||
* Information about the exception if an 'exception' stopped event raised and DA supports the 'exceptionInfo' request, otherwise null. | ||
*/ | ||
exceptionInfo: TPromise<DebugProtocol.ExceptionInfoResponse>; | ||
|
||
/** | ||
* Gets the callstack if it has already been received from the debug | ||
* adapter, otherwise it returns null. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -490,6 +490,18 @@ export class Thread implements IThread { | |
}); | ||
} | ||
|
||
/** | ||
* Returns exception info promise if the exception was thrown and the debug adapter supports 'exceptionInfo' request, otherwise null | ||
*/ | ||
public get exceptionInfo(): TPromise<DebugProtocol.ExceptionInfoResponse> { | ||
const session = this.process.session; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would love if the exception widget always calls this method. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We might need to introduce an interface on our side as a pair of adapter protocol exception interface - to get rid of the body and to handle the case when the session does not support exception request |
||
if (session.capabilities.supportsExceptionInfoRequest && this.stoppedDetails && this.stoppedDetails.reason === 'exception') { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do not like this check for this.stoppedDetails and this.stoppedDetails.reason === 'exception' since now we do it two times. Once before calling this method and once in the method. We should do it in only one of those places - whichever feels better to you. |
||
return session.exceptionInfo({ threadId: this.threadId }); | ||
} | ||
|
||
return null; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can not just return |
||
} | ||
|
||
public next(): TPromise<any> { | ||
return this.process.session.next({ threadId: this.threadId }); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -323,6 +323,10 @@ export class RawDebugSession extends v8.V8Protocol implements debug.ISession { | |
return this.send('stackTrace', args); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks good |
||
} | ||
|
||
public exceptionInfo(args: DebugProtocol.ExceptionInfoArguments): TPromise<DebugProtocol.ExceptionInfoResponse> { | ||
return this.send('exceptionInfo', args); | ||
} | ||
|
||
public scopes(args: DebugProtocol.ScopesArguments): TPromise<DebugProtocol.ScopesResponse> { | ||
return this.send('scopes', args); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -120,6 +120,15 @@ export class MockSession implements debug.ISession { | |
}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks good |
||
} | ||
|
||
public exceptionInfo(args: DebugProtocol.ExceptionInfoArguments): TPromise<DebugProtocol.ExceptionInfoResponse> { | ||
return TPromise.as({ | ||
body: { | ||
exceptionId: 'mockExceptionId', | ||
breakMode: 'unhandled' | ||
} | ||
}); | ||
} | ||
|
||
public attach(args: DebugProtocol.AttachRequestArguments): TPromise<DebugProtocol.AttachResponse> { | ||
return TPromise.as(null); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer if the default case had the same
Exception occurred
message as the case when there is no exceptionInfo