Bug 1942009 - [devtools] Log error message when pretty print fails to handle a script r=ochameau,devtools-reviewers
Depends on D234020 In case of pretty printing error, we display the error from the worker, from the action dispatcher. We could log the source which failed to be pretty printed, especially for html inline scripts where several small scripts will be prettified independantly. Differential Revision: https://phabricator.services.mozilla.com/D234172
This commit is contained in:
@@ -2,8 +2,10 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
|
||||
|
||||
import { truncateString } from "devtools/shared/string";
|
||||
import { WorkerDispatcher } from "devtools/client/shared/worker-utils";
|
||||
|
||||
const MAX_SCRIPT_LOG_LENGTH = 500;
|
||||
const WORKER_URL =
|
||||
"resource://devtools/client/debugger/dist/pretty-print-worker.js";
|
||||
|
||||
@@ -16,12 +18,28 @@ export class PrettyPrintDispatcher extends WorkerDispatcher {
|
||||
#prettyPrintInlineScriptTask = this.task("prettyPrintInlineScript");
|
||||
#getSourceMapForTask = this.task("getSourceMapForTask");
|
||||
|
||||
prettyPrint(options) {
|
||||
return this.#prettyPrintTask(options);
|
||||
async prettyPrint(options) {
|
||||
try {
|
||||
return await this.#prettyPrintTask(options);
|
||||
} catch (e) {
|
||||
console.error(
|
||||
`[pretty-print] Failed to pretty print script (${options.url}):\n`,
|
||||
truncateString(options.sourceText, MAX_SCRIPT_LOG_LENGTH)
|
||||
);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
prettyPrintInlineScript(options) {
|
||||
return this.#prettyPrintInlineScriptTask(options);
|
||||
async prettyPrintInlineScript(options) {
|
||||
try {
|
||||
return await this.#prettyPrintInlineScriptTask(options);
|
||||
} catch (e) {
|
||||
console.error(
|
||||
`[pretty-print] Failed to pretty print inline script (${options.url}):\n`,
|
||||
truncateString(options.sourceText, MAX_SCRIPT_LOG_LENGTH)
|
||||
);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
getSourceMap(taskId) {
|
||||
|
||||
@@ -5,9 +5,7 @@
|
||||
"use strict";
|
||||
|
||||
const TextEditor = require("resource://devtools/client/inspector/markup/views/text-editor.js");
|
||||
const {
|
||||
truncateString,
|
||||
} = require("resource://devtools/shared/inspector/utils.js");
|
||||
const { truncateString } = require("resource://devtools/shared/string.js");
|
||||
const {
|
||||
editableField,
|
||||
InplaceEditor,
|
||||
|
||||
@@ -11,9 +11,7 @@ const {
|
||||
const {
|
||||
moveInfobar,
|
||||
} = require("resource://devtools/server/actors/highlighters/utils/markup.js");
|
||||
const {
|
||||
truncateString,
|
||||
} = require("resource://devtools/shared/inspector/utils.js");
|
||||
const { truncateString } = require("resource://devtools/shared/string.js");
|
||||
|
||||
const STRINGS_URI = "devtools/shared/locales/accessibility.properties";
|
||||
loader.lazyRequireGetter(
|
||||
|
||||
@@ -6,9 +6,7 @@
|
||||
|
||||
// Test the accessible highlighter's infobar content.
|
||||
|
||||
const {
|
||||
truncateString,
|
||||
} = require("resource://devtools/shared/inspector/utils.js");
|
||||
const { truncateString } = require("resource://devtools/shared/string.js");
|
||||
const {
|
||||
MAX_STRING_LENGTH,
|
||||
} = require("resource://devtools/server/actors/highlighters/utils/accessibility.js");
|
||||
|
||||
@@ -4,4 +4,4 @@
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
DevToolsModules("css-logic.js", "utils.js")
|
||||
DevToolsModules("css-logic.js")
|
||||
|
||||
@@ -69,6 +69,7 @@ DevToolsModules(
|
||||
"picker-constants.js",
|
||||
"plural-form.js",
|
||||
"protocol.js",
|
||||
"string.js",
|
||||
"system.js",
|
||||
"ThreadSafeDevToolsUtils.js",
|
||||
"throttle.js",
|
||||
|
||||
Reference in New Issue
Block a user