Skip to content

Commit

Permalink
Improve messaging when the API fails to download a file (#1396)
Browse files Browse the repository at this point in the history
  • Loading branch information
j-f1 authored Jul 24, 2023
1 parent b8c90aa commit 9c527e3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions packages/loot-core/src/server/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ handlers['api/download-budget'] = async function ({ syncId, password }) {

let result = await handlers['download-budget']({ fileId: file.fileId });
if (result.error) {
console.log('Full error details', result.error);
throw new Error(getDownloadError(result.error));
}
await handlers['load-budget']({ id: result.id });
Expand Down
7 changes: 4 additions & 3 deletions packages/loot-core/src/shared/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,11 @@ export function getDownloadError({ reason, meta, fileName }) {
);

default:
let info = meta && meta.fileId ? `(fileId: ${meta.fileId})` : '';
let info = meta && meta.fileId ? `, fileId: ${meta.fileId}` : '';
return (
'Something went wrong trying to download that file, sorry! Visit https://actualbudget.org/contact/ for support. ' +
info
'Something went wrong trying to download that file, sorry! ' +
'Visit https://actualbudget.org/contact/ for support. ' +
`(reason: ${reason}${info})`
);
}
}
Expand Down
6 changes: 6 additions & 0 deletions upcoming-release-notes/1396.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Enhancements
authors: [j-f1]
---

Improve error messaging when the API package fails to download a file

0 comments on commit 9c527e3

Please sign in to comment.