mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-16 06:18:42 +02:00
UI: Show "undefined" instead of -1 as pid in error popup when catching promise errors (#2555)
This commit is contained in:
@@ -9,7 +9,7 @@ let currentId = 0;
|
||||
export const DisplayError = (message: string, errorType: string, ws: WorkerScript | null = null) => {
|
||||
const scriptName = ws?.scriptRef?.filename ?? "";
|
||||
const hostname = ws?.hostname ?? "";
|
||||
const pid = ws?.pid ?? -1;
|
||||
const pid = ws?.pid;
|
||||
const parsedMessage = ws ? parseBlobUrlInMessage(ws, message) : message;
|
||||
const errorPageOpen = Router.page() === SimplePage.RecentErrors;
|
||||
if (!errorPageOpen) {
|
||||
@@ -19,7 +19,7 @@ export const DisplayError = (message: string, errorType: string, ws: WorkerScrip
|
||||
if (prior) {
|
||||
prior.occurrences++;
|
||||
prior.time = new Date();
|
||||
if (pid !== -1) {
|
||||
if (pid !== undefined) {
|
||||
prior.pid = pid;
|
||||
}
|
||||
prior.server = hostname;
|
||||
@@ -37,6 +37,7 @@ export const DisplayError = (message: string, errorType: string, ws: WorkerScrip
|
||||
occurrences: 1,
|
||||
time: new Date(),
|
||||
unread: !errorPageOpen,
|
||||
force: false,
|
||||
});
|
||||
while (ErrorState.Errors.length > 100) {
|
||||
ErrorState.Errors.pop();
|
||||
|
||||
@@ -73,7 +73,7 @@ export function ErrorModal(): React.ReactElement {
|
||||
<p>
|
||||
Script: {error.scriptName}
|
||||
<br />
|
||||
PID: {error.pid}
|
||||
PID: {String(error.pid)}
|
||||
</p>
|
||||
{!Settings.SuppressErrorModals && (
|
||||
<OptionSwitch
|
||||
@@ -92,7 +92,7 @@ export function ErrorModal(): React.ReactElement {
|
||||
<Box className={classes.inlineFlexBox}>
|
||||
<Button onClick={() => onClose()}>Close</Button>
|
||||
<div>
|
||||
<Button disabled={error.pid === -1} onClick={viewLogs}>
|
||||
<Button disabled={error.pid === undefined} onClick={viewLogs}>
|
||||
View Script Logs
|
||||
</Button>
|
||||
<Button onClick={goToErrorPage}>Errors Page</Button>
|
||||
|
||||
@@ -6,11 +6,11 @@ export type ErrorRecord = {
|
||||
errorType: string;
|
||||
message: string;
|
||||
scriptName: string;
|
||||
pid: number;
|
||||
pid?: number;
|
||||
occurrences: number;
|
||||
time: Date;
|
||||
unread: boolean;
|
||||
force?: boolean;
|
||||
force: boolean;
|
||||
};
|
||||
|
||||
export const ErrorState = {
|
||||
|
||||
Reference in New Issue
Block a user