Skip to content
This repository has been archived by the owner on Jul 23, 2023. It is now read-only.

Commit

Permalink
Show error on failed config read
Browse files Browse the repository at this point in the history
  • Loading branch information
Raicuparta committed May 13, 2021
1 parent e8c39d8 commit 6801f3d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion app/helpers/static-text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,15 @@ export const modsText = {
missingManifestAttributesError: (path: string, attributes: string[]) =>
`Manifest ${path} missing attributes "${attributes.join('", "')}"`,
modLoadError: (errors: string[]) =>
`Failed to load mod. Errors: ${errors.join(' || ')}`,
`Encountered problems loading the mod: ${errors.join(' || ')}`,
actionError: (action: string, error: string) =>
`Error executing mod ${action}: ${error}`,
duplicateModError: (modUniqueName: string) =>
`Found multiple mods with the same uniqueName (${modUniqueName}). Open the mods directory and make sure you only have one copy of each mod.`,
brokenManifestError: (directoryName: string) =>
`Failed to read manifest.json in mod directory "${directoryName}". Reinstall the mod or contact the mod author to fix this issue.`,
brokenConfigError: (error: string) =>
`Failed to read mod configuration files: "${error}"`,
};

export const settingsText = {
Expand Down
3 changes: 2 additions & 1 deletion app/services/mod-config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import fs from 'fs-extra';
import { debugConsole } from '../helpers/console-log';
import { modsText } from '../helpers/static-text';

function getDefaultConfigPath(mod: Mod) {
return `${mod.modPath}/default-config.json`;
Expand Down Expand Up @@ -39,7 +40,7 @@ export function getConfig(mod: Mod) {
const config: ModConfig = fs.readJsonSync(getConfigPath(mod));
return config;
} catch (error) {
debugConsole.error('error trying to get config', error);
mod.errors.push(modsText.brokenConfigError(error));
return undefined;
}
}

0 comments on commit 6801f3d

Please sign in to comment.