Skip to content

Commit

Permalink
Add error handling to extension load (#13204)
Browse files Browse the repository at this point in the history
* Add error handling to extension load

* Fix formatting following rebase
  • Loading branch information
nwmac authored Jan 31, 2025
1 parent 478e195 commit 56fbea3
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions shell/core/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export default function(context, inject, vueApp) {
element.dataset.purpose = 'extension';

element.onload = () => {
if (!window[id]) {
if (!window[id] || (typeof window[id].default !== 'function')) {
return reject(new Error('Could not load plugin code'));
}

Expand All @@ -106,7 +106,13 @@ export default function(context, inject, vueApp) {
plugins[id] = plugin;

// Initialize the plugin
window[id].default(plugin, this.internal());
try {
window[id].default(plugin, this.internal());
} catch (e) {
delete plugins[id];

return reject(new Error('Could not initialize plugin'));
}

// Load all of the types etc from the plugin
this.applyPlugin(plugin);
Expand Down

0 comments on commit 56fbea3

Please sign in to comment.