refactor: error handling

Meant to push this before release.
Ensures errors are handled as before, regardless of using exports
or lib/mysql; for compatibility.
This commit is contained in:
Linden committed 2022-06-18 16:32:07 +10:00
1 parent a709f67e99
commit 15884fbc82
4 files changed
+7 -7

No files matched your search

+1 -1
View File
@@ -3,7 +3,7 @@ game 'common'
name 'oxmysql'
description 'Database wrapper for FiveM utilising node-mysql2 offering improved performance and security.'
version '2.3.2'
version '2.3.3'
url 'https://github.com/overextended/oxmysql'
author 'overextended'
+2 -2
View File
@@ -74,7 +74,7 @@ local function await(fn, query, parameters)
end
p:resolve(result)
end, GetCurrentResourceName, false)
end, GetCurrentResourceName, true)
return Await(p)
end
@@ -86,7 +86,7 @@ setmetatable(MySQL, {
__call = function(_, query, parameters, cb)
query, parameters, cb = safeArgs(query, parameters, cb, method == 'transaction')
return oxmysql[method](nil, query, parameters, cb, GetCurrentResourceName, true)
return oxmysql[method](nil, query, parameters, cb, GetCurrentResourceName, false)
end,
__index = function(_, index)
+2 -2
View File
@@ -77,7 +77,7 @@ export const rawExecute = async (
.catch((err) => {
const error = `${invokingResource} was unable to execute a query!\n${err}\n${`${query}`}`;
if (cb && !throwError) cb(null, error);
if (throwError || !cb) throw new Error(error);
if (cb && throwError) return cb(null, error);
throw new Error(error);
});
};
+2 -2
View File
@@ -30,7 +30,7 @@ export const rawQuery = async (
}).catch((err) => {
const error = `${invokingResource} was unable to execute a query!\n${err.message}\n${`${query} ${JSON.stringify(parameters)}`}`
if (cb && !throwError) cb(null, error);
if (throwError || !cb) throw new Error(error);
if (cb && throwError) return cb(null, error);
throw new Error(error);
});
};