mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-05-05 15:17:48 +02:00
MISC: Add error cause to exceptionAlert and Recovery mode (#1772)
This commit is contained in:
@@ -50,7 +50,22 @@ export function AlertManager({ hidden }: { hidden: boolean }): React.ReactElemen
|
||||
if (typeof text === "string") {
|
||||
return cyrb53(text);
|
||||
}
|
||||
return cyrb53(JSON.stringify(text.props));
|
||||
/**
|
||||
* JSON.stringify may throw an error in edge cases. One possible error is "TypeError: Converting circular structure
|
||||
* to JSON". It may happen in very special cases. This is the flow of one of them:
|
||||
* - An error occurred in GameRoot.tsx and we show a warning popup by calling "exceptionAlert" without delaying.
|
||||
* - "exceptionAlert" constructs a React element and passes it via "dialogBoxCreate" -> "AlertEvents.emit".
|
||||
* - When we receive the final React element here, the element's "props" property may contain a circular structure.
|
||||
*/
|
||||
let textPropsAsString;
|
||||
try {
|
||||
textPropsAsString = JSON.stringify(text.props);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
// Use the current timestamp as the fallback value.
|
||||
textPropsAsString = Date.now().toString();
|
||||
}
|
||||
return cyrb53(textPropsAsString);
|
||||
}
|
||||
|
||||
function close(): void {
|
||||
|
||||
Reference in New Issue
Block a user