A local-first personal finance app
pass causes along in failed-to-load exceptions (#3525)
Ryan Bianchif79edf866a53
diff --git a/packages/desktop-client/src/components/util/LoadComponent.tsx b/packages/desktop-client/src/components/util/LoadComponent.tsxindex 3a180373c5..cff5fe26cc 100644--- a/packages/desktop-client/src/components/util/LoadComponent.tsx+++ b/packages/desktop-client/src/components/util/LoadComponent.tsx@@ -34,6 +34,7 @@ function LoadComponentInner<K extends string>({localModuleCache.get(name) ?? null,);const [failedToLoad, setFailedToLoad] = useState(false);+ const [failedToLoadException, setFailedToLoadException] = useState(null);useEffect(() => {if (localModuleCache.has(name)) {@@ -55,13 +56,14 @@ function LoadComponentInner<K extends string>({{retries: 5,},- ).catch(() => {+ ).catch(e => {setFailedToLoad(true);+ setFailedToLoadException(e);});}, [name, importer]);if (failedToLoad) {- throw new LazyLoadFailedError(name);+ throw new LazyLoadFailedError(name, failedToLoadException);}if (!Component) {diff --git a/packages/loot-core/src/shared/errors.ts b/packages/loot-core/src/shared/errors.tsindex a6489b1e8b..ff8815c81e 100644--- a/packages/loot-core/src/shared/errors.ts+++ b/packages/loot-core/src/shared/errors.ts@@ -100,8 +100,9 @@ export class LazyLoadFailedError extends Error {type = 'app-init-failure';meta = {};- constructor(name: string) {+ constructor(name: string, cause: unknown) {super(`Error: failed loading lazy-loaded module ${name}`);this.meta = { name };+ this.cause = cause;}}diff --git a/upcoming-release-notes/3525.md b/upcoming-release-notes/3525.mdnew file mode 100644index 0000000000..06481bc3e0--- /dev/null+++ b/upcoming-release-notes/3525.md@@ -0,0 +1,6 @@+---+category: Maintenance+authors: [qedi-r]+---++Expose underlying exception source when a module fails to load.