提交 8e293fdf 编写于 作者: M Michel Kaporin

Added exception condition message. Moved exceptionInfo query logic to debugEditor.

上级 b3048512
......@@ -11,14 +11,11 @@ import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
import { IContextViewService } from 'vs/platform/contextview/browser/contextView';
import { IDebugService } from 'vs/workbench/parts/debug/common/debug';
import { RunOnceScheduler } from 'vs/base/common/async';
import { TPromise } from 'vs/base/common/winjs.base';
const $ = dom.$;
export class ExceptionWidget extends ZoneWidget {
private exceptionInfo: TPromise<DebugProtocol.ExceptionInfoResponse>;
constructor(editor: ICodeEditor, private lineNumber: number,
constructor(editor: ICodeEditor, private exceptionInfo: DebugProtocol.ExceptionInfoResponse, private lineNumber: number,
@IContextViewService private contextViewService: IContextViewService,
@IDebugService private debugService: IDebugService
) {
......@@ -42,16 +39,32 @@ export class ExceptionWidget extends ZoneWidget {
let title = $('.title');
let msg = $('.message');
this.exceptionInfo = thread.exceptionInfo;
this.exceptionInfo.then((exceptionInfo) => {
if (exceptionInfo) {
title.textContent = exceptionInfo.body.description;
msg.textContent = exceptionInfo.body.details.stackTrace;
} else {
title.textContent = nls.localize('exceptionThrown', 'Exception occurred');
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}`;
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);
......@@ -59,12 +72,10 @@ export class ExceptionWidget extends ZoneWidget {
}
protected _doLayout(heightInPixel: number, widthInPixel: number): void {
this.exceptionInfo.then(() => {
// Reload the height with respect to the exception text content and relayout it to match the line count.
this.container.style.height = 'initial';
// Reload the height with respect to the exception text content and relayout it to match the line count.
this.container.style.height = 'initial';
const computedLinesNumber = Math.ceil(this.container.offsetHeight / this.editor.getConfiguration().fontInfo.lineHeight);
this._relayout(computedLinesNumber);
});
const computedLinesNumber = Math.ceil(this.container.offsetHeight / this.editor.getConfiguration().fontInfo.lineHeight);
this._relayout(computedLinesNumber);
}
}
......@@ -135,7 +135,7 @@ 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.
* Information about the exception if an 'exception' stopped event raised and DA supports the 'exceptionInfo' request, otherwise null.
*/
exceptionInfo: TPromise<DebugProtocol.ExceptionInfoResponse>;
......
......@@ -361,16 +361,18 @@ export class DebugEditorContribution implements IDebugEditorContribution {
if (this.exceptionWidget && !sameUri) {
this.closeExceptionWidget();
} else if (sameUri && focusedSf.thread.stoppedDetails && focusedSf.thread.stoppedDetails.reason === 'exception') {
this.showExceptionWidget(exceptionSf.lineNumber, exceptionSf.column);
focusedSf.thread.exceptionInfo.then((exceptionInfo) => {
this.showExceptionWidget(null, exceptionSf.lineNumber, exceptionSf.column);
});
}
}
private showExceptionWidget(lineNumber: number, column: number): void {
private showExceptionWidget(exceptionInfo: DebugProtocol.ExceptionInfoResponse, lineNumber: number, column: number): void {
if (this.exceptionWidget) {
this.exceptionWidget.dispose();
}
this.exceptionWidget = this.instantiationService.createInstance(ExceptionWidget, this.editor, lineNumber);
this.exceptionWidget = this.instantiationService.createInstance(ExceptionWidget, this.editor, exceptionInfo, lineNumber);
this.exceptionWidget.show({ lineNumber, column }, 0);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册