Major bug fixes + updated contributing guidelines

This commit is contained in:
DJj123dj
2024-11-06 20:59:00 +01:00
parent 319bbe318d
commit 4022ae49c2
7 changed files with 123 additions and 23 deletions
+7 -2
View File
@@ -1,7 +1,7 @@
///////////////////////////////////////
//DATABASE MODULE
///////////////////////////////////////
import { ODId, ODManager, ODManagerData, ODValidId, ODValidJsonType } from "./base"
import { ODId, ODManager, ODManagerData, ODSystemError, ODValidId, ODValidJsonType } from "./base"
import fs from "fs"
import nodepath from "path"
import { ODDebugger } from "./console"
@@ -203,7 +203,12 @@ export class ODJsonDatabase extends ODDatabase {
/**Read parsed data from the json file */
getData: (): ODJsonDatabaseStructure => {
if (fs.existsSync(this.file)){
return JSON.parse(fs.readFileSync(this.file).toString())
try{
return JSON.parse(fs.readFileSync(this.file).toString())
}catch(err){
process.emit("uncaughtException",err)
throw new ODSystemError("Unable to read database "+this.file+"! getData() read error. (see error above)")
}
}else{
fs.writeFileSync(this.file,"[]")
return []