diff --git a/src/App.vue b/src/App.vue index f266cc52..c1468afe 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,25 +1,7 @@ @@ -64,8 +46,13 @@ import GenericProfileInstaller from './r2mm/installing/profile_installers/Generi import ConnectionProviderImpl from './r2mm/connection/ConnectionProviderImpl'; import ConnectionProvider from './providers/generic/connection/ConnectionProvider'; import UtilityMixin from './components/mixins/UtilityMixin.vue'; +import ErrorModal from './components/modals/ErrorModal.vue'; -@Component +@Component({ + components: { + ErrorModal, + } +}) export default class App extends mixins(UtilityMixin) { private settings: ManagerSettings | null = null; private visible: boolean = false; diff --git a/src/components/config-components/ConfigSelectionLayout.vue b/src/components/config-components/ConfigSelectionLayout.vue index e319d2ce..e9956499 100644 --- a/src/components/config-components/ConfigSelectionLayout.vue +++ b/src/components/config-components/ConfigSelectionLayout.vue @@ -145,9 +145,9 @@ import ProfileModList from '../../r2mm/mods/ProfileModList'; this.configFiles = this.configFiles.filter(value => value.getName() !== file.getName()); this.textChanged(); } catch (e) { - this.$emit("error", new R2Error( + this.$store.commit("error/handleError", R2Error.fromThrownValue( + e, "Failed to delete config file", - (e as Error).message, `Try running ${ManagerInformation.APP_NAME} as an administrator.` )); } diff --git a/src/components/importing/LocalFileImportModal.vue b/src/components/importing/LocalFileImportModal.vue index 2973d9ef..2680a49e 100644 --- a/src/components/importing/LocalFileImportModal.vue +++ b/src/components/importing/LocalFileImportModal.vue @@ -289,12 +289,12 @@ export default class LocalFileImportModal extends Vue { const installCallback = (async (success: boolean, error: any | null) => { if (!success && error !== null) { - this.showError(error); + this.$store.commit("error/handleError", R2Error.fromThrownValue(error)); return; } const updatedModListResult = await ProfileModList.getModList(this.contextProfile!); if (updatedModListResult instanceof R2Error) { - this.showError(updatedModListResult); + this.$store.commit("error/handleError", updatedModListResult); return; } await this.$store.dispatch("updateModList", updatedModListResult); @@ -308,10 +308,6 @@ export default class LocalFileImportModal extends Vue { } } - private showError(err: R2Error) { - this.$emit("error", err); - } - created() { this.contextProfile = Profile.getActiveProfile(); } diff --git a/src/components/mixins/UtilityMixin.vue b/src/components/mixins/UtilityMixin.vue index f40317c1..b430b27d 100644 --- a/src/components/mixins/UtilityMixin.vue +++ b/src/components/mixins/UtilityMixin.vue @@ -6,32 +6,15 @@ import R2Error from '../../model/errors/R2Error'; import GameManager from '../../model/game/GameManager'; import Profile from '../../model/Profile'; import CdnProvider from '../../providers/generic/connection/CdnProvider'; -import LoggerProvider, { LogSeverity } from '../../providers/ror2/logging/LoggerProvider'; import ThunderstorePackages from '../../r2mm/data/ThunderstorePackages'; import ProfileModList from '../../r2mm/mods/ProfileModList'; import ApiCacheUtils from '../../utils/ApiCacheUtils'; @Component export default class UtilityMixin extends Vue { - private errorMessage: string = ''; - private errorStack: string = ''; - private errorSolution: string = ''; readonly REFRESH_INTERVAL = 5 * 60 * 1000; private tsRefreshFailed = false; - showError(error: R2Error) { - this.errorMessage = error.name; - this.errorStack = error.message; - this.errorSolution = error.solution; - LoggerProvider.instance.Log(LogSeverity.ERROR, `[${error.name}]: ${error.message}`); - } - - closeErrorModal() { - this.errorMessage = ''; - this.errorStack = ''; - this.errorSolution = ''; - } - hookProfileModListRefresh() { setInterval(this.refreshProfileModList, this.REFRESH_INTERVAL); } @@ -101,7 +84,7 @@ export default class UtilityMixin extends Vue { await CdnProvider.checkCdnConnection(); } catch (error: unknown) { if (error instanceof R2Error) { - this.showError(error); + this.$store.commit('error/handleError', error); } else { console.error(error); } diff --git a/src/components/modals/ErrorModal.vue b/src/components/modals/ErrorModal.vue new file mode 100644 index 00000000..b8cd429b --- /dev/null +++ b/src/components/modals/ErrorModal.vue @@ -0,0 +1,51 @@ + + + + + diff --git a/src/components/navigation/NavigationLayout.vue b/src/components/navigation/NavigationLayout.vue index d7801328..ad7dbff0 100644 --- a/src/components/navigation/NavigationLayout.vue +++ b/src/components/navigation/NavigationLayout.vue @@ -1,10 +1,10 @@