(
details: Cdp.Runtime.ExceptionDetails,
prefix?: string,
)
| 1085 | } |
| 1086 | |
| 1087 | async _formatException( |
| 1088 | details: Cdp.Runtime.ExceptionDetails, |
| 1089 | prefix?: string, |
| 1090 | ): Promise<Dap.OutputEventParams> { |
| 1091 | const preview = details.exception |
| 1092 | ? objectPreview.previewException(details.exception) |
| 1093 | : { title: '' }; |
| 1094 | let message = preview.title; |
| 1095 | if (!message.startsWith('Uncaught')) message = 'Uncaught ' + message; |
| 1096 | message = (prefix || '') + message; |
| 1097 | |
| 1098 | let stackTrace: StackTrace | undefined; |
| 1099 | let uiLocation: IUiLocation | undefined; |
| 1100 | if (details.stackTrace) stackTrace = StackTrace.fromRuntime(this, details.stackTrace); |
| 1101 | if (stackTrace) { |
| 1102 | const frames = await stackTrace.loadFrames(1); |
| 1103 | if (frames.length) uiLocation = await frames[0].uiLocation(); |
| 1104 | } |
| 1105 | |
| 1106 | const args = details.exception && !preview.stackTrace ? [details.exception] : []; |
| 1107 | let variablesReference = 0; |
| 1108 | if (stackTrace || args.length) |
| 1109 | variablesReference = await this.replVariables.createVariableForOutput( |
| 1110 | message, |
| 1111 | args, |
| 1112 | stackTrace, |
| 1113 | ); |
| 1114 | |
| 1115 | return { |
| 1116 | category: 'stderr', |
| 1117 | output: message, |
| 1118 | variablesReference, |
| 1119 | source: uiLocation ? await uiLocation.source.toDap() : undefined, |
| 1120 | line: uiLocation ? uiLocation.lineNumber : undefined, |
| 1121 | column: uiLocation ? uiLocation.columnNumber : undefined, |
| 1122 | }; |
| 1123 | } |
| 1124 | |
| 1125 | scriptsFromSource(source: Source): Set<Script> { |
| 1126 | return this._sourceScripts.get(source) || new Set(); |
no test coverage detected