From b1dcb4da41a804f2f338aa5d37d316328b472db0 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Fri, 30 Apr 2021 22:46:43 +1000 Subject: [PATCH] Web: Show error in chat if fail to sync filesystem to IndexedDB --- src/Platform.c | 6 ++++++ src/interop_web.c | 9 ++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/Platform.c b/src/Platform.c index 3814788ed..9bd75b8e6 100644 --- a/src/Platform.c +++ b/src/Platform.c @@ -1731,6 +1731,12 @@ void Platform_Init(void) { Platform_InitSpecific(); } #elif defined CC_BUILD_WEB +EMSCRIPTEN_KEEPALIVE void Platform_LogError(const char* msg) { + /* no pointer showing more than 128 characters in chat */ + cc_string str = String_FromRaw(msg, 128); + Logger_WarnFunc(&str); +} + extern void interop_InitModule(void); extern void interop_GetIndexedDBError(char* buffer); void Platform_Init(void) { diff --git a/src/interop_web.c b/src/interop_web.c index 580054032..c37f90f9d 100644 --- a/src/interop_web.c +++ b/src/interop_web.c @@ -127,7 +127,14 @@ void interop_GetIndexedDBError(char* buffer) { } void interop_SyncFS(void) { - EM_ASM( FS.syncfs(false, function(err) { if (err) console.log(err); }); ); + EM_ASM({ + FS.syncfs(false, function(err) { + if (!err) return; + console.log(err); + ccall('Platform_LogError', 'void', ['string'], ['&cError saving IndexedDB:']); + ccall('Platform_LogError', 'void', ['string'], [' &c' + err]); + }); + }); } int interop_OpenTab(const char* url) {