diff --git a/localization/locales/en/translation.json b/localization/locales/en/translation.json index d10aceca..86f40ecd 100644 --- a/localization/locales/en/translation.json +++ b/localization/locales/en/translation.json @@ -281,7 +281,9 @@ "InsertMenuAfterSubMenuIndexErrorDescription": "E-5 You try to insert menu with afterSubMenu \"{afterSubMenu}\" in menu \"{menuID}\", but we can not found it in menu \"{menu}\", please specific a menuitem with correct id attribute", "MainWindowMissing": "This program can't access main window data, can't run normally.", "InitWikiGitSyncedWikiNoGitUserInfoError": "InitWikiGitSyncedWikiNoGitUserInfoErrorDescription", - "InitWikiGitSyncedWikiNoGitUserInfoErrorDescription": "E-6 Initializing the note repository synchronized to the cloud requires you to select a cloud git repository address and provide the certification credentials for the corresponding cloud service. However, this information is not currently available." + "InitWikiGitSyncedWikiNoGitUserInfoErrorDescription": "E-6 Initializing the note repository synchronized to the cloud requires you to select a cloud git repository address and provide the certification credentials for the corresponding cloud service. However, this information is not currently available.", + "WorkspaceFailedToLoadError": "WorkspaceFailedToLoadError", + "WorkspaceFailedToLoadErrorDescription": "The Wiki page corresponding to the workspace failed to load. There are many reasons, but it is basically because of program bugs." }, "Loading": "Loading", "Yes": "Yes", diff --git a/localization/locales/zh_CN/translation.json b/localization/locales/zh_CN/translation.json index 12b6629f..daec7a86 100644 --- a/localization/locales/zh_CN/translation.json +++ b/localization/locales/zh_CN/translation.json @@ -309,7 +309,9 @@ "InsertMenuAfterSubMenuIndexErrorDescription": "E-5 你尝试插入目录,且 afterSubMenu \"{afterSubMenu}\" 在目录 menuID \"{menuID}\" 内,但我们无法在目录 \"{menu}\" 里找到它,请用正确的 menuID 指定一个目录。", "InitWikiGitSyncedWikiNoGitUserInfoError": "笔记仓库初始化失败因为没有提供Git信息错误", "InitWikiGitSyncedWikiNoGitUserInfoErrorDescription": "E-6 初始化同步到云端的笔记仓库需要你选择一个云端的 git 仓库地址,还有提供相应云服务的认证凭证,然而目前没有获得这些信息。", - "MainWindowMissing": "程序无法获取主窗口信息,无法正常运行。" + "MainWindowMissing": "程序无法获取主窗口信息,无法正常运行。", + "WorkspaceFailedToLoadError": "工作区加载失败错误", + "WorkspaceFailedToLoadErrorDescription": "工作区对应的Wiki网页加载失败了,原因有很多,但基本是因为程序Bug" }, "Loading": "加载中", "Yes": "是的", diff --git a/src/services/workspacesView/error.ts b/src/services/workspacesView/error.ts new file mode 100644 index 00000000..c0b5f069 --- /dev/null +++ b/src/services/workspacesView/error.ts @@ -0,0 +1,9 @@ +import i18n from '@services/libs/i18n'; + +export class WorkspaceFailedToLoadError extends Error { + constructor(extraMessage?: string, url?: string) { + super(extraMessage); + this.name = i18n.t('Error.WorkspaceFailedToLoadError'); + this.message = `${i18n.t('Error.WorkspaceFailedToLoadErrorDescription')} ${extraMessage ?? ''} ${url ?? ''}`; + } +} diff --git a/src/services/workspacesView/index.ts b/src/services/workspacesView/index.ts index fb735380..4977770e 100644 --- a/src/services/workspacesView/index.ts +++ b/src/services/workspacesView/index.ts @@ -19,6 +19,7 @@ import { IWikiService } from '@services/wiki/interface'; import { IWorkspaceViewService } from './interface'; import { lazyInject } from '@services/container'; import { SupportedStorageServices } from '@services/types'; +import { WorkspaceFailedToLoadError } from './error'; @injectable() export class WorkspaceView implements IWorkspaceViewService { @@ -62,7 +63,7 @@ export class WorkspaceView implements IWorkspaceViewService { } await this.viewService.addView(mainWindow, workspace); const userInfo = await this.authService.getStorageServiceUserInfo(workspace.storageService); - const { wikiFolderLocation, gitUrl: githubRepoUrl, storageService } = workspace; + const { wikiFolderLocation, gitUrl: githubRepoUrl, storageService, homeUrl } = workspace; // wait for main wiki's watch-fs plugin to be fully initialized // and also wait for wiki BrowserView to be able to receive command // eslint-disable-next-line global-require @@ -76,7 +77,7 @@ export class WorkspaceView implements IWorkspaceViewService { } loadFailed = typeof workspaceMetadata.didFailLoadErrorMessage === 'string' && workspaceMetadata.didFailLoadErrorMessage.length > 0; if (loadFailed) { - throw new Error(workspaceMetadata.didFailLoadErrorMessage!); + throw new WorkspaceFailedToLoadError(workspaceMetadata.didFailLoadErrorMessage!, homeUrl); } // get sync process ready try {