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

@@ -49,7 +49,10 @@ func GetDocument(serverName *C.char, databaseId *C.char, collectionId *C.char, d
return C.CString("")
}
documentJson, _ := json.Marshal(document)
documentJson, err := json.Marshal(document)
if err != nil {
return C.CString("")
}
return C.CString(string(documentJson))
}
@@ -70,7 +73,10 @@ func GetAllDocuments(serverName *C.char, databaseId *C.char, collectionId *C.cha
return C.CString("")
}
documentsJson, _ := json.Marshal(documents)
documentsJson, err := json.Marshal(documents)
if err != nil {
return C.CString("")
}
return C.CString(string(documentsJson))
}