mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 14:22:01 +00:00
Bug 1201215 - Implement more robust error handling for DevToolsWorker; r=jsantell
This commit is contained in:
parent
38abca5fc5
commit
9d8b5d43fc
@ -102,8 +102,29 @@
|
||||
}
|
||||
}
|
||||
|
||||
function handleError(e="Error") {
|
||||
self.postMessage({ id, error: e.message || e });
|
||||
function handleError(error="Error") {
|
||||
try {
|
||||
// First, try and structured clone the error across directly.
|
||||
self.postMessage({ id, error });
|
||||
} catch (_) {
|
||||
// We could not clone whatever error value was given. Do our best to
|
||||
// stringify it.
|
||||
let errorString = `Error while performing task "${task}": `;
|
||||
|
||||
try {
|
||||
errorString += error.toString();
|
||||
} catch (_) {
|
||||
errorString += "<could not stringify error>";
|
||||
}
|
||||
|
||||
if ("stack" in error) {
|
||||
try {
|
||||
errorString += "\n" + error.stack;
|
||||
} catch (_) { }
|
||||
}
|
||||
|
||||
self.postMessage({ id, error: errorString });
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user