Skip to content

Commit 3df746e

Browse files
authored
Merge pull request #1531 from ebkr/gdweave-error
Improve GDWeave's error message and general mod installation error handling
2 parents e56097f + 1462470 commit 3df746e

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/installers/GDWeaveInstaller.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import FileUtils from '../utils/FileUtils';
1010
import { MODLOADER_PACKAGES } from '../r2mm/installing/profile_installers/ModLoaderVariantRecord';
1111
import { PackageLoader } from '../model/installing/PackageLoader';
1212
import FileWriteError from '../model/errors/FileWriteError';
13+
import R2Error from '../model/errors/R2Error';
1314

1415
export class GDWeaveInstaller implements PackageInstaller {
1516
async install(args: InstallArgs) {
@@ -105,7 +106,10 @@ export class GDWeavePluginInstaller implements PackageInstaller {
105106
// not at the top level (because the top level is Thunderstore's packaging)
106107
const modFolderInCache = await searchForManifest(args.packagePath);
107108
if (!modFolderInCache) {
108-
throw new Error('Could not find mod folder');
109+
throw new R2Error(
110+
'Could not find mod folder',
111+
'Either the mod package is malformed, or the files extracted to cache are corrupted'
112+
);
109113
}
110114

111115
const modFolderInProfile = this.getModFolderInProfile(args);

src/r2mm/installing/profile_installers/GenericProfileInstaller.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,12 @@ export default class GenericProfileInstaller extends ProfileInstallerProvider {
171171
const pluginInstaller = GetInstallerIdForPlugin(GameManager.activeGame.packageLoader);
172172

173173
if (pluginInstaller !== null) {
174-
await PackageInstallers[pluginInstaller].install(args);
175-
return Promise.resolve(null);
174+
try {
175+
await PackageInstallers[pluginInstaller].install(args);
176+
return Promise.resolve(null);
177+
} catch (e) {
178+
return Promise.resolve(R2Error.fromThrownValue(e));
179+
}
176180
}
177181

178182
// Revert to legacy install behavior.

0 commit comments

Comments
 (0)