fix: throw error msg
This commit is contained in:
@@ -285,20 +285,11 @@ const messageHandlers = {
|
|||||||
*/
|
*/
|
||||||
browser.runtime.onMessage.addListener(async ({ action, args }) => {
|
browser.runtime.onMessage.addListener(async ({ action, args }) => {
|
||||||
const handler = messageHandlers[action];
|
const handler = messageHandlers[action];
|
||||||
|
|
||||||
if (!handler) {
|
if (!handler) {
|
||||||
const errorMessage = `Message action is unavailable: ${action}`;
|
throw new Error(`Message action is unavailable: ${action}`);
|
||||||
kissLog("runtime onMessage", action, new Error(errorMessage));
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
return handler(args);
|
||||||
const result = await handler(args);
|
|
||||||
return result;
|
|
||||||
} catch (err) {
|
|
||||||
kissLog("runtime onMessage", action, err);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ export function AlertProvider({ children }) {
|
|||||||
onClose={handleClose}
|
onClose={handleClose}
|
||||||
anchorOrigin={{ vertical, horizontal }}
|
anchorOrigin={{ vertical, horizontal }}
|
||||||
>
|
>
|
||||||
<Alert onClose={handleClose} severity={severity} sx={{ width: "100%" }}>
|
<Alert onClose={handleClose} severity={severity} sx={{ maxWidth: "80%" }}>
|
||||||
{message}
|
{message}
|
||||||
</Alert>
|
</Alert>
|
||||||
</Snackbar>
|
</Snackbar>
|
||||||
|
|||||||
@@ -41,6 +41,12 @@ export const fetchGM = async (
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
onerror: reject,
|
onerror: reject,
|
||||||
|
onabort: () => {
|
||||||
|
reject(new Error("GM request onabort."));
|
||||||
|
},
|
||||||
|
ontimeout: () => {
|
||||||
|
reject(new Error("GM request timeout."));
|
||||||
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -77,24 +77,7 @@ function TestButton({ api }) {
|
|||||||
alert.error(
|
alert.error(
|
||||||
<>
|
<>
|
||||||
<div>{i18n("test_failed")}</div>
|
<div>{i18n("test_failed")}</div>
|
||||||
{msg === err.message ? (
|
{msg === err.message ? <div>{msg}</div> : <pre>{msg}</pre>}
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
maxWidth: 400,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{msg}
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
<pre
|
|
||||||
style={{
|
|
||||||
maxWidth: 400,
|
|
||||||
overflow: "auto",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{msg}
|
|
||||||
</pre>
|
|
||||||
)}
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
Reference in New Issue
Block a user