diff --git a/src/electron/main.ts b/src/electron/main.ts index d2a84680a..617d58588 100644 --- a/src/electron/main.ts +++ b/src/electron/main.ts @@ -270,20 +270,38 @@ const userStore = new ElectronStore(); const project = Project.from(message.payload); const library = project.getPatternLibrary(); - const analysis = await Analyzer.analyze(path, { - getGobalEnumOptionId: (patternId, contextId) => - library.assignEnumOptionId(patternId, contextId), - getGlobalPatternId: contextId => library.assignPatternId(contextId), - getGlobalPropertyId: (patternId, contextId) => - library.assignPropertyId(patternId, contextId), - getGlobalSlotId: (patternId, contextId) => library.assignSlotId(patternId, contextId) - }); + try { + const analysis = await Analyzer.analyze(path, { + getGobalEnumOptionId: (patternId, contextId) => + library.assignEnumOptionId(patternId, contextId), + getGlobalPatternId: contextId => library.assignPatternId(contextId), + getGlobalPropertyId: (patternId, contextId) => + library.assignPropertyId(patternId, contextId), + getGlobalSlotId: (patternId, contextId) => + library.assignSlotId(patternId, contextId) + }); - send({ - type: ServerMessageType.ConnectPatternLibraryResponse, - id: message.id, - payload: analysis - }); + send({ + type: ServerMessageType.ConnectPatternLibraryResponse, + id: message.id, + payload: analysis + }); + } catch { + dialog.showMessageBox( + { + message: + 'Sorry, this seems to be an uncompatible library. Learn more about supported component libraries on github.com/meetalva', + buttons: ['OK', 'Learn more'] + }, + response => { + if (response === 1) { + shell.openExternal( + 'https://github.com/meetalva/alva#pattern-library-requirements' + ); + } + } + ); + } break; } @@ -305,20 +323,38 @@ const userStore = new ElectronStore(); return; } - const analysis = await Analyzer.analyze(connection.path, { - getGobalEnumOptionId: (patternId, contextId) => - library.assignEnumOptionId(patternId, contextId), - getGlobalPatternId: contextId => library.assignPatternId(contextId), - getGlobalPropertyId: (patternId, contextId) => - library.assignPropertyId(patternId, contextId), - getGlobalSlotId: (patternId, contextId) => library.assignSlotId(patternId, contextId) - }); + try { + const analysis = await Analyzer.analyze(connection.path, { + getGobalEnumOptionId: (patternId, contextId) => + library.assignEnumOptionId(patternId, contextId), + getGlobalPatternId: contextId => library.assignPatternId(contextId), + getGlobalPropertyId: (patternId, contextId) => + library.assignPropertyId(patternId, contextId), + getGlobalSlotId: (patternId, contextId) => + library.assignSlotId(patternId, contextId) + }); - send({ - type: ServerMessageType.ConnectPatternLibraryResponse, - id: message.id, - payload: analysis - }); + send({ + type: ServerMessageType.ConnectPatternLibraryResponse, + id: message.id, + payload: analysis + }); + } catch { + dialog.showMessageBox( + { + message: + 'Sorry, this seems to be an uncompatible library. Learn more about supported component libraries on github.com/meetalva', + buttons: ['OK', 'Learn more'] + }, + response => { + if (response === 1) { + shell.openExternal( + 'https://github.com/meetalva/alva#pattern-library-requirements' + ); + } + } + ); + } break; }