Skip to content

A local-first personal finance app

🐛 Extra error handling for if user has incorrect server url (#3736)

Michael Clarka6da06a8efdb
diff --git a/packages/loot-core/src/server/server-config.ts b/packages/loot-core/src/server/server-config.ts
index 79f4933254..df30b721f4 100644
--- a/packages/loot-core/src/server/server-config.ts
+++ b/packages/loot-core/src/server/server-config.ts
@@ -27,13 +27,22 @@ export function setServer(url: string): void {
// `url` is optional; if not given it will provide the global config
export function getServer(url?: string): ServerConfig | null {
if (url) {
- return {
- BASE_SERVER: url,
- SYNC_SERVER: joinURL(url, '/sync'),
- SIGNUP_SERVER: joinURL(url, '/account'),
- GOCARDLESS_SERVER: joinURL(url, '/gocardless'),
- SIMPLEFIN_SERVER: joinURL(url, '/simplefin'),
- };
+ try {
+ return {
+ BASE_SERVER: url,
+ SYNC_SERVER: joinURL(url, '/sync'),
+ SIGNUP_SERVER: joinURL(url, '/account'),
+ GOCARDLESS_SERVER: joinURL(url, '/gocardless'),
+ SIMPLEFIN_SERVER: joinURL(url, '/simplefin'),
+ };
+ } catch (error) {
+ console.warn(
+ 'Unable to parse server URL - using the global config.',
+ { config },
+ error,
+ );
+ return config;
+ }
}
return config;
}
diff --git a/upcoming-release-notes/3736.md b/upcoming-release-notes/3736.md
new file mode 100644
index 0000000000..71d80fd35f
--- /dev/null
+++ b/upcoming-release-notes/3736.md
@@ -0,0 +1,6 @@
+---
+category: Bugfix
+authors: [MikesGlitch]
+---
+
+Add extra error handling for when an incorrect server URL has been setup