Skip to content

Commit f69a36b

Browse files
committed
MOBILE-4653 core: Fix message not stored in cache for CoreWSError
When storing a CoreWSError in cache, for example for a nopermission error, the message was lost so the next time the error was used it had no message.
1 parent 10ccf38 commit f69a36b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/core/classes/sites/authenticated-site.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,11 @@ export class CoreAuthenticatedSite extends CoreUnauthenticatedSite {
737737

738738
if (preSets.saveToCache) {
739739
// Save the error instead of deleting the cache entry so the same content is displayed in offline.
740-
this.saveToCache(method, data, error, preSets);
740+
// Create a new error object when storing, otherwise the message is not stored with CoreWSError.
741+
this.saveToCache(method, data, {
742+
...error,
743+
message: error.message,
744+
}, preSets);
741745
}
742746

743747
throw new CoreWSError(error);

0 commit comments

Comments
 (0)