Fix #26, show details of thrown thing when it's not an object

This commit is contained in:
Rob 2015-11-07 21:19:10 -08:00
Родитель 5e0f1c1494
Коммит 8f43833743
3 изменённых файлов: 26 добавлений и 7 удалений

Просмотреть файл

@ -48,7 +48,7 @@ suite('ConsoleHelper', () => {
test('network error', () => {
doAssert(Console.makeNetworkLog('neterror', 'myurl'), 'neterror (myurl)', true);
})
});
test('objects- waiting on VS Code bug 20343');
});

Просмотреть файл

@ -16,6 +16,7 @@ import * as path from 'path';
export class WebKitDebugAdapter implements IDebugAdapter {
private static THREAD_ID = 1;
private static PAGE_PAUSE_MESSAGE = 'Paused in Visual Studio Code';
private static EXCEPTION_VALUE_ID = 'EXCEPTION_VALUE_ID';
private _clientLinesStartAt1: boolean;
@ -24,6 +25,7 @@ export class WebKitDebugAdapter implements IDebugAdapter {
private _currentStack: WebKitProtocol.Debugger.CallFrame[];
private _committedBreakpointsByUrl: Map<string, WebKitProtocol.Debugger.BreakpointId[]>;
private _overlayHelper: utils.DebounceHelper;
private _exceptionValueObject: WebKitProtocol.Runtime.RemoteObject;
private _chromeProc: ChildProcess;
private _webKitConnection: WebKitConnection;
@ -201,10 +203,23 @@ export class WebKitDebugAdapter implements IDebugAdapter {
let exceptionText: string;
if (notification.reason === 'exception') {
reason = 'exception';
exceptionText = notification.data.description;
if (notification.data && notification.data.objectId && this._currentStack.length) {
// Insert a scope to wrap the exception object. exceptionText is unused at the moment
this._currentStack[0].scopeChain.unshift({ type: 'Exception', object: notification.data });
if (notification.data && this._currentStack.length) {
// Insert a scope to wrap the exception object. exceptionText is unused by Code at the moment.
const remoteObjValue = utils.remoteObjectToValue(notification.data, false);
let scopeObject: WebKitProtocol.Runtime.RemoteObject;
if (remoteObjValue.variableHandleRef) {
// If the remote object is an object (probably an Error), treat the object like a scope.
exceptionText = notification.data.description;
scopeObject = notification.data;
} else {
// If it's a value, use a special flag and save the value for later.
exceptionText = notification.data.value;
scopeObject = <any>{ objectId: WebKitDebugAdapter.EXCEPTION_VALUE_ID };
this._exceptionValueObject = notification.data;
}
this._currentStack[0].scopeChain.unshift({ type: 'Exception', object: scopeObject });
}
} else {
reason = notification.hitBreakpoints.length ? 'breakpoint' : 'step';
@ -441,7 +456,11 @@ export class WebKitDebugAdapter implements IDebugAdapter {
public variables(args: DebugProtocol.VariablesArguments): Promise<VariablesResponseBody> {
const id = this._variableHandles.get(args.variablesReference);
if (id != null) {
if (id === WebKitDebugAdapter.EXCEPTION_VALUE_ID) {
// If this is the special marker for an exception value, create a fake property descriptor so the usual route can be used
const excValuePropDescriptor: WebKitProtocol.Runtime.PropertyDescriptor = <any>{ name: 'exception', value: this._exceptionValueObject };
return Promise.resolve({ variables: [ this.propertyDescriptorToVariable(excValuePropDescriptor)] });
} else if (id != null) {
return this._webKitConnection.runtime_getProperties(id, /*ownProperties=*/true).then(getPropsResponse => {
const variables = getPropsResponse.error ? [] :
getPropsResponse.result.result.map(propDesc => this.propertyDescriptorToVariable(propDesc));

2
webkit/webKitProtocol.d.ts поставляемый
Просмотреть файл

@ -49,7 +49,7 @@ declare namespace WebKitProtocol {
callFrames: CallFrame[];
// 'exception' or 'other'
reason: string;
data: any;
data: Runtime.RemoteObject;
hitBreakpoints: BreakpointId[];
}