| @@ -97,21 +97,19 @@ | ||
| 97 | 97 | |
| 98 | 98 | try { |
| 99 | 99 | await fn(slug); |
| 100 | 100 | return true; |
| 101 | - } catch (_) { | |
| 102 | - try { | |
| 103 | - // try once more but get the slug first | |
| 104 | - const { plugin } = await getPlugin(slug); | |
| 105 | - await fn(plugin); | |
| 106 | - return true; | |
| 107 | - } catch (error) { | |
| 101 | + } catch (error) { | |
| 102 | + const report = (e) => { | |
| 108 | 103 | digest({ |
| 109 | - error, | |
| 104 | + error: e, | |
| 110 | 105 | details: { source: 'auto-launch', caller: 'activatePlugin' }, |
| 111 | 106 | }); |
| 112 | 107 | return false; |
| 113 | - } | |
| 108 | + }; | |
| 109 | + const found = await getPlugin(slug).catch(() => undefined); | |
| 110 | + if (!found?.plugin) return report(error); | |
| 111 | + return fn(found.plugin).then(() => true, report); | |
| 114 | 112 | } |
| 115 | 113 | }; |
| 116 | 114 | |
| 117 | 115 | // Exact match, not substring: woocommerce-payments would mask a missing woocommerce. |