tested and fixed

This commit is contained in:
2024-10-31 07:47:27 +03:00
parent 7a2ab7dd5b
commit c9e679ec4c
22 changed files with 91 additions and 66 deletions

View File

@@ -4,7 +4,7 @@ import responseCodes from "../response/responseCodes.js";
const errorHandler = (e, obj) => {
switch (e.code) {
case '23505':
throw new customError(`Duplicate ${obj}`, responseCodes.responses[obs].duplicate)
throw new customError(`Duplicate ${obj}`, responseCodes.responses[obj].duplicate)
case '22007':
throw new customError(`Invalid syntax ${obj}`, responseCodes.responses.general.invalid_syntax)
case '22001':

View File

@@ -1,7 +1,9 @@
import fs from 'fs';
const translate = (language, code) => {
if (!language) language = "en-US"
if (!code) code = "unknown"
return JSON.parse(fs.readFileSync(`../../messages/${language}/msgs.json`).toString())[code]
return JSON.parse(fs.readFileSync(`./messages/${language}/msgs.json`).toString())[code];
}
export default translate