Add more error handling and mutex guards

This commit is contained in:
Pijus Kamandulis
2025-01-27 21:09:37 +02:00
parent d6b816b55a
commit 125f10d8a2
8 changed files with 62 additions and 26 deletions

View File

@@ -47,7 +47,10 @@ func GetCollection(serverName *C.char, databaseId *C.char, collectionId *C.char)
return C.CString("")
}
collectionJson, _ := json.Marshal(collection)
collectionJson, err := json.Marshal(collection)
if err != nil {
return C.CString("")
}
return C.CString(string(collectionJson))
}
@@ -67,7 +70,10 @@ func GetAllCollections(serverName *C.char, databaseId *C.char) *C.char {
return C.CString("")
}
collectionsJson, _ := json.Marshal(collections)
collectionsJson, err := json.Marshal(collections)
if err != nil {
return C.CString("")
}
return C.CString(string(collectionsJson))
}