Web: Show error in chat if fail to sync filesystem to IndexedDB

This commit is contained in:
UnknownShadow200 2021-04-30 22:46:43 +10:00
parent 9c2b28ca88
commit b1dcb4da41
2 changed files with 14 additions and 1 deletions

View File

@ -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) {

View File

@ -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) {