mirror of
https://github.com/frappe/books.git
synced 2024-11-10 07:40:55 +00:00
incr: error handle lastSelectedFilepath load
This commit is contained in:
parent
6ace4677e7
commit
a8904a0854
21
src/App.vue
21
src/App.vue
@ -34,8 +34,10 @@
|
||||
|
||||
<script>
|
||||
import { ConfigKeys } from 'fyo/core/types';
|
||||
import { getSetupComplete, incrementOpenCount } from 'src/utils/misc';
|
||||
import { ModelNameEnum } from 'models/types';
|
||||
import { incrementOpenCount } from 'src/utils/misc';
|
||||
import WindowsTitleBar from './components/WindowsTitleBar.vue';
|
||||
import { handleErrorWithDialog } from './errorHandling';
|
||||
import { fyo, initializeInstance } from './initFyo';
|
||||
import DatabaseSelector from './pages/DatabaseSelector.vue';
|
||||
import Desk from './pages/Desk.vue';
|
||||
@ -66,12 +68,16 @@ export default {
|
||||
null
|
||||
);
|
||||
|
||||
if (lastSelectedFilePath) {
|
||||
await this.fileSelected(lastSelectedFilePath, false);
|
||||
return;
|
||||
if (!lastSelectedFilePath) {
|
||||
return (this.activeScreen = 'DatabaseSelector');
|
||||
}
|
||||
|
||||
this.activeScreen = 'DatabaseSelector';
|
||||
try {
|
||||
await this.fileSelected(lastSelectedFilePath, false);
|
||||
} catch (err) {
|
||||
await handleErrorWithDialog(err, undefined, true, true);
|
||||
this.activeScreen = 'DatabaseSelector';
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
async setDesk(filePath) {
|
||||
@ -96,7 +102,10 @@ export default {
|
||||
},
|
||||
async showSetupWizardOrDesk(filePath) {
|
||||
const countryCode = await fyo.db.connectToDatabase(filePath);
|
||||
const setupComplete = await getSetupComplete();
|
||||
const setupComplete = await fyo.getValue(
|
||||
ModelNameEnum.AccountingSettings,
|
||||
'setupComplete'
|
||||
);
|
||||
|
||||
if (!setupComplete) {
|
||||
this.activeScreen = 'SetupWizard';
|
||||
|
@ -7,10 +7,12 @@ import {
|
||||
ValidationError,
|
||||
} from 'fyo/utils/errors';
|
||||
import { ErrorLog } from 'fyo/utils/types';
|
||||
import { truncate } from 'lodash';
|
||||
import { IPC_ACTIONS, IPC_MESSAGES } from 'utils/messages';
|
||||
import { fyo } from './initFyo';
|
||||
import router from './router';
|
||||
import { getErrorMessage } from './utils';
|
||||
import { ToastOptions } from './utils/types';
|
||||
import { MessageDialogOptions, ToastOptions } from './utils/types';
|
||||
import { showMessageDialog, showToast } from './utils/ui';
|
||||
|
||||
function shouldNotStore(error: Error) {
|
||||
@ -32,7 +34,6 @@ async function reportError(errorLogObj: ErrorLog, cb?: Function) {
|
||||
};
|
||||
|
||||
if (fyo.store.isDevelopment) {
|
||||
console.log('errorHandling');
|
||||
console.log(body);
|
||||
}
|
||||
|
||||
@ -85,12 +86,39 @@ export async function handleError(
|
||||
await showToast(toastProps);
|
||||
}
|
||||
|
||||
export async function handleErrorWithDialog(error: Error, doc?: Doc) {
|
||||
export async function handleErrorWithDialog(
|
||||
error: Error,
|
||||
doc?: Doc,
|
||||
reportError?: false,
|
||||
dontThrow?: false
|
||||
) {
|
||||
const errorMessage = getErrorMessage(error, doc);
|
||||
await handleError(false, error, { errorMessage, doc });
|
||||
|
||||
const name = error.name ?? t`Error`;
|
||||
await showMessageDialog({ message: name, detail: errorMessage });
|
||||
const options: MessageDialogOptions = { message: name, detail: errorMessage };
|
||||
|
||||
if (reportError) {
|
||||
options.detail = truncate(options.detail, { length: 128 });
|
||||
options.buttons = [
|
||||
{
|
||||
label: t`Report`,
|
||||
action() {
|
||||
reportIssue(getErrorLogObject(error, { errorMessage }));
|
||||
},
|
||||
},
|
||||
{ label: t`OK`, action() {} },
|
||||
];
|
||||
}
|
||||
|
||||
await showMessageDialog(options);
|
||||
if (dontThrow) {
|
||||
if (fyo.store.isDevelopment) {
|
||||
console.error(error);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
throw error;
|
||||
}
|
||||
|
||||
@ -157,6 +185,9 @@ function getIssueUrlQuery(errorLogObj?: ErrorLog): string {
|
||||
body.push(`**Path**: \`${fullPath}\``);
|
||||
}
|
||||
|
||||
body.push(`**Version**: ${fyo.store.appVersion}`);
|
||||
body.push(`**Route**: ${router.currentRoute.value.fullPath}`);
|
||||
|
||||
const url = [baseUrl, `body=${body.join('\n')}`].join('&');
|
||||
return encodeURI(url);
|
||||
}
|
||||
|
@ -167,7 +167,7 @@ import { setupDummyInstance } from 'dummy';
|
||||
import { ipcRenderer } from 'electron';
|
||||
import { t } from 'fyo';
|
||||
import { ConfigKeys } from 'fyo/core/types';
|
||||
import { addNewFile } from 'fyo/telemetry/helpers';
|
||||
import { addNewConfigFile } from 'fyo/telemetry/helpers';
|
||||
import { DateTime } from 'luxon';
|
||||
import LanguageSelector from 'src/components/Controls/LanguageSelector.vue';
|
||||
import FeatherIcon from 'src/components/FeatherIcon.vue';
|
||||
@ -242,7 +242,7 @@ export default {
|
||||
}
|
||||
);
|
||||
|
||||
addNewFile(
|
||||
addNewConfigFile(
|
||||
companyName,
|
||||
filePath,
|
||||
instanceId,
|
||||
|
Loading…
Reference in New Issue
Block a user