mirror of
https://github.com/darksaid98/oxmysql.git
synced 2026-12-05 06:28:53 +00:00
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:
1 parent
a709f67e99
commit
15884fbc82
4 files changed
+7
-7
No files matched your search
+1
-1
@@ -3,7 +3,7 @@ game 'common'
|
|||||||
|
|
||||||
name 'oxmysql'
|
name 'oxmysql'
|
||||||
description 'Database wrapper for FiveM utilising node-mysql2 offering improved performance and security.'
|
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'
|
url 'https://github.com/overextended/oxmysql'
|
||||||
author 'overextended'
|
author 'overextended'
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -74,7 +74,7 @@ local function await(fn, query, parameters)
|
|||||||
end
|
end
|
||||||
|
|
||||||
p:resolve(result)
|
p:resolve(result)
|
||||||
end, GetCurrentResourceName, false)
|
end, GetCurrentResourceName, true)
|
||||||
return Await(p)
|
return Await(p)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -86,7 +86,7 @@ setmetatable(MySQL, {
|
|||||||
|
|
||||||
__call = function(_, query, parameters, cb)
|
__call = function(_, query, parameters, cb)
|
||||||
query, parameters, cb = safeArgs(query, parameters, cb, method == 'transaction')
|
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,
|
end,
|
||||||
|
|
||||||
__index = function(_, index)
|
__index = function(_, index)
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ export const rawExecute = async (
|
|||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
const error = `${invokingResource} was unable to execute a query!\n${err}\n${`${query}`}`;
|
const error = `${invokingResource} was unable to execute a query!\n${err}\n${`${query}`}`;
|
||||||
|
|
||||||
if (cb && !throwError) cb(null, error);
|
if (cb && throwError) return cb(null, error);
|
||||||
if (throwError || !cb) throw new Error(error);
|
throw new Error(error);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -30,7 +30,7 @@ export const rawQuery = async (
|
|||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
const error = `${invokingResource} was unable to execute a query!\n${err.message}\n${`${query} ${JSON.stringify(parameters)}`}`
|
const error = `${invokingResource} was unable to execute a query!\n${err.message}\n${`${query} ${JSON.stringify(parameters)}`}`
|
||||||
|
|
||||||
if (cb && !throwError) cb(null, error);
|
if (cb && throwError) return cb(null, error);
|
||||||
if (throwError || !cb) throw new Error(error);
|
throw new Error(error);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
Reference in new issue
Block a user