mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-04 10:32:34 +00:00
also add try catch block
This commit is contained in:
+6
-2
@@ -55,7 +55,7 @@ class WebViewWidgetMessageInterceptor(
|
|||||||
view.evaluateJavascript(
|
view.evaluateJavascript(
|
||||||
"""
|
"""
|
||||||
// Removing any parts that result in a circular structure. Circular structures crash JSON.stringify.
|
// Removing any parts that result in a circular structure. Circular structures crash JSON.stringify.
|
||||||
function simpleStringify(object) {
|
function safeStringify(object) {
|
||||||
const simpleObject = {};
|
const simpleObject = {};
|
||||||
for (const prop in object) {
|
for (const prop in object) {
|
||||||
if (!object.hasOwnProperty(prop)) {
|
if (!object.hasOwnProperty(prop)) {
|
||||||
@@ -69,13 +69,17 @@ class WebViewWidgetMessageInterceptor(
|
|||||||
}
|
}
|
||||||
simpleObject[prop] = object[prop];
|
simpleObject[prop] = object[prop];
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
return JSON.stringify(simpleObject);
|
return JSON.stringify(simpleObject);
|
||||||
|
} catch {
|
||||||
|
return "{Failed to stringify object}";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function logFn(consoleLogFn, ...args) {
|
function logFn(consoleLogFn, ...args) {
|
||||||
consoleLogFn(
|
consoleLogFn(
|
||||||
args.map(
|
args.map(
|
||||||
a => typeof a === "string" ? a : simpleStringify(a)
|
a => typeof a === "string" ? a : safeStringify(a)
|
||||||
).join(' ')
|
).join(' ')
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user