Skip to content

Commit

Permalink
fix(skymp5-client): fix error handling in load order verification (#2031
Browse files Browse the repository at this point in the history
)
  • Loading branch information
Pospelove authored Jun 11, 2024
1 parent 2cd2c17 commit cf6a6e3
Showing 1 changed file with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { getServerIp, getServerUiPort } from "./skympClient";
import { getScreenResolution } from "../../view/formView";
import { ClientListener, CombinedController, Sp } from "./clientListener";
import { Mod, ServerManifest } from "../messages_http/serverManifest";
import { logTrace } from "../../logging";

const STATE_KEY = 'loadOrderCheckState';

Expand Down Expand Up @@ -136,7 +137,7 @@ export class LoadOrderVerificationService extends ClientListener {
const result = [];
for (let i = 0; i < getCount(); ++i) {
const filename = getAt(i);
const { crc32, size } = this.sp.getFileInfo(filename);
const { crc32, size } = this.getFileInfoSafe(filename);
result.push({ filename, crc32, size });
}
return result;
Expand All @@ -152,4 +153,24 @@ export class LoadOrderVerificationService extends ClientListener {
printConsole(`#${i} ${JSON.stringify(mod)}`);
}
};

private getFileInfoSafe(filename: string) {
try {
return this.sp.getFileInfo(filename);
}
catch (e) {
// InvalidArgumentException.h, Skyrim Platform
const searchString = 'is not a valid argument';

const message = (e as Record<string, unknown>).message;

if (typeof message === "string" && message.includes('is not a valid argument')) {
logTrace(this, `Failed to get file info for`, filename);
return { crc32: 0, size: 0 };
}
else {
throw e;
}
}
}
}

0 comments on commit cf6a6e3

Please sign in to comment.