mirror of
https://github.com/darksaid98/oxmysql.git
synced 2026-12-02 06:28:54 +00:00
fix(database): throw Error before creating promise
Promises, even when resolved/rejected immediately after their creation, will destroy any useful information from a stack trace when used over events/exports. Since some people still use the exports rather than MySQL/lib.lua, and for some reason don't know the correct syntax for Lua exports (i.e. using exports.oxmysql.query instead of the CORRECT exports.oxmysql:query) it's comically common for an "untraceable" error to get spit out. Will this help? No. Will everyone expect me to solve their issues? Yes. Go update your scripts to use MySQL/lib.lua and we can all get along stress-free.
This commit is contained in:
1 parent
30e37af313
commit
5a949b9546
3 files changed
+24
-14
No files matched your search
@@ -9,8 +9,6 @@ export const parseArguments = (
|
||||
parameters?: CFXParameters,
|
||||
cb?: CFXCallback
|
||||
): [string, CFXParameters, CFXCallback | undefined] => {
|
||||
if (typeof query !== 'string') throw new Error(`Query expected a string but received ${typeof query} instead`);
|
||||
|
||||
if (convertNamedPlaceholders && parameters && typeof parameters === 'object' && !Array.isArray(parameters))
|
||||
if (query.includes(':') || query.includes('@')) {
|
||||
const placeholders = convertNamedPlaceholders(query, parameters);
|
||||
@@ -42,9 +40,11 @@ export const parseArguments = (
|
||||
if (diff > 0) {
|
||||
for (let i = 0; i < diff; i++) parameters[queryParams.length + i] = null;
|
||||
} else if (diff < 0) {
|
||||
throw new Error(`${invokingResource} was unable to execute a query!
|
||||
Expected ${queryParams.length} parameters, but received ${parameters.length}.
|
||||
${`${query} ${JSON.stringify(parameters)}`}`);
|
||||
throw new Error(
|
||||
`${invokingResource} was unable to execute a query!\nExpected ${
|
||||
queryParams.length
|
||||
} parameters, but received ${parameters.length}.\n${`${query} ${JSON.stringify(parameters)}`}`
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user