Skip to content

Commit

Permalink
Merge pull request #1531 from ebkr/gdweave-error
Browse files Browse the repository at this point in the history
Improve GDWeave's error message and general mod installation error handling
  • Loading branch information
anttimaki authored Nov 11, 2024
2 parents e56097f + 1462470 commit 3df746e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/installers/GDWeaveInstaller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import FileUtils from '../utils/FileUtils';
import { MODLOADER_PACKAGES } from '../r2mm/installing/profile_installers/ModLoaderVariantRecord';
import { PackageLoader } from '../model/installing/PackageLoader';
import FileWriteError from '../model/errors/FileWriteError';
import R2Error from '../model/errors/R2Error';

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

const modFolderInProfile = this.getModFolderInProfile(args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,12 @@ export default class GenericProfileInstaller extends ProfileInstallerProvider {
const pluginInstaller = GetInstallerIdForPlugin(GameManager.activeGame.packageLoader);

if (pluginInstaller !== null) {
await PackageInstallers[pluginInstaller].install(args);
return Promise.resolve(null);
try {
await PackageInstallers[pluginInstaller].install(args);
return Promise.resolve(null);
} catch (e) {
return Promise.resolve(R2Error.fromThrownValue(e));
}
}

// Revert to legacy install behavior.
Expand Down

0 comments on commit 3df746e

Please sign in to comment.