Index: binaries/data/mods/public/gui/common/campaigns/CampaignRun.js =================================================================== --- binaries/data/mods/public/gui/common/campaigns/CampaignRun.js +++ binaries/data/mods/public/gui/common/campaigns/CampaignRun.js @@ -2,6 +2,26 @@ // TODO: Move this to a static member once linters accept it. var g_CurrentCampaignRun; +class CampaignRunDoesNotExistError extends Error +{ + toString() + { + return sprintf(translate("Campaign file %(file)s does not exist."), { + "file": this.message + }); + } +}; + +class CampaignTemplateCannotLoadError extends Error +{ + toString() + { + return sprintf(translate("Campaign template %(file)s does not exist (perhaps it comes from a mod?)."), { + "file": this.message + }); + } +} + /** * A campaign "Run" saves metadata on a campaign progession. * It is equivalent to a saved game for a game. @@ -122,13 +142,13 @@ load() { if (!Engine.FileExists("saves/campaigns/" + this.filename + ".0adcampaign")) - throw new Error("Campaign file does not exist"); + throw new CampaignRunDoesNotExistError(this.filename); let data = Engine.ReadJSONFile("saves/campaigns/" + this.filename + ".0adcampaign"); this.data = data.data; this.meta = data.meta; this.template = CampaignTemplate.getTemplate(data.template_identifier); if (!this.template) - throw new Error("Campaign template " + data.template_identifier + " does not exist (perhaps it comes from a mod?)"); + throw new CampaignTemplateCannotLoadError(data.template_identifier); return this; }