mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-21 09:38:01 +02:00
Desktop: Include more information when auto-generating import error report
This commit is contained in:
parent
a2ded180cb
commit
17c25b72f0
@ -666,6 +666,7 @@ packages/lib/import-enex.js
|
||||
packages/lib/initLib.js
|
||||
packages/lib/locale.test.js
|
||||
packages/lib/locale.js
|
||||
packages/lib/makeDiscourseDebugUrl.test.js
|
||||
packages/lib/makeDiscourseDebugUrl.js
|
||||
packages/lib/markdownUtils.test.js
|
||||
packages/lib/markdownUtils.js
|
||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -646,6 +646,7 @@ packages/lib/import-enex.js
|
||||
packages/lib/initLib.js
|
||||
packages/lib/locale.test.js
|
||||
packages/lib/locale.js
|
||||
packages/lib/makeDiscourseDebugUrl.test.js
|
||||
packages/lib/makeDiscourseDebugUrl.js
|
||||
packages/lib/markdownUtils.test.js
|
||||
packages/lib/markdownUtils.js
|
||||
|
18
packages/lib/makeDiscourseDebugUrl.test.ts
Normal file
18
packages/lib/makeDiscourseDebugUrl.test.ts
Normal file
@ -0,0 +1,18 @@
|
||||
import { renderErrorBlock } from './makeDiscourseDebugUrl';
|
||||
|
||||
describe('makeDiscourseDebugUrl', () => {
|
||||
|
||||
it('should render errors', () => {
|
||||
const errors = [
|
||||
new Error('First'),
|
||||
new Error('Second'),
|
||||
'Just a plain string',
|
||||
];
|
||||
|
||||
const actual = renderErrorBlock(errors);
|
||||
expect(actual.startsWith('```\nError: First\n at Object')).toBe(true);
|
||||
expect(actual.includes(')\n\nError: Second\n at Object')).toBe(true);
|
||||
expect(actual.endsWith(')\n\nJust a plain string\n```')).toBe(true);
|
||||
});
|
||||
|
||||
});
|
@ -2,9 +2,12 @@ import { PluginSettings } from './services/plugins/PluginService';
|
||||
import type PluginService from './services/plugins/PluginService';
|
||||
import versionInfo, { PackageInfo } from './versionInfo';
|
||||
|
||||
const renderErrorBlock = (errors: any[]): string => {
|
||||
export const renderErrorBlock = (errors: (string | Error)[]): string => {
|
||||
if (!errors.length) return '';
|
||||
return `\`\`\`\n${errors.map(e => typeof e === 'string' ? e.trim() : e.message.trim())}\n\`\`\``;
|
||||
return `\`\`\`\n${errors.map(e => {
|
||||
if (typeof e === 'string') return e.trim();
|
||||
return e.message.trim() + e.stack ? `\n${e.stack}` : '';
|
||||
}).map(l => l.trim()).join('\n\n')}\n\`\`\``;
|
||||
};
|
||||
|
||||
const getOsName = (platform: typeof process.platform) => {
|
||||
@ -15,7 +18,7 @@ const getOsName = (platform: typeof process.platform) => {
|
||||
return '';
|
||||
};
|
||||
|
||||
export default (title: string, body: string, errors: any[], packageInfo: PackageInfo, pluginService: PluginService, pluginSettings: PluginSettings) => {
|
||||
export default (title: string, body: string, errors: (string | Error)[], packageInfo: PackageInfo, pluginService: PluginService, pluginSettings: PluginSettings) => {
|
||||
const v = versionInfo(packageInfo, pluginService.enabledPlugins(pluginSettings));
|
||||
|
||||
const errorBlock = renderErrorBlock(errors);
|
||||
|
Loading…
Reference in New Issue
Block a user