mirror of
https://github.com/darksaid98/oxmysql.git
synced 2026-12-01 22:21:51 +00:00
fix(db): move query responses to their own try block
Other resources with script errors (notably "attempt to index a nil value") would mistakenly report the query as failed, and people would assume ANY reported errors were because of oxmysql, even through it was their own awful script. No errors should be thrown in oxmysql when an error occurs in a function reference.
This commit is contained in:
1 parent
7b4ae91dbe
commit
afc04fc553
5 files changed
+24
-19
No files matched your search
@@ -2,7 +2,7 @@ import { pool } from '.';
|
||||
import { parseArguments } from '../utils/parseArguments';
|
||||
import { parseResponse } from '../utils/parseResponse';
|
||||
import { logQuery } from '../logger';
|
||||
import type { CFXCallback, CFXParameters } from '../types';
|
||||
import type { CFXCallback, CFXParameters, QueryResponse } from '../types';
|
||||
import type { QueryType } from '../types';
|
||||
import { scheduleTick } from '../utils/scheduleTick';
|
||||
|
||||
@@ -14,6 +14,7 @@ export const rawQuery = async (
|
||||
cb?: CFXCallback
|
||||
) => {
|
||||
await scheduleTick();
|
||||
let response: QueryResponse;
|
||||
|
||||
try {
|
||||
[query, parameters, cb] = parseArguments(invokingResource, query, parameters, cb);
|
||||
@@ -22,9 +23,7 @@ export const rawQuery = async (
|
||||
|
||||
logQuery(invokingResource, query, executionTime, parameters);
|
||||
|
||||
const response = parseResponse(type, result);
|
||||
|
||||
return cb ? cb(response) : response;
|
||||
response = parseResponse(type, result);
|
||||
} catch (e) {
|
||||
throw new Error(
|
||||
`${invokingResource} was unable to execute a query!\n${(e as Error).message}\n${
|
||||
@@ -32,4 +31,8 @@ export const rawQuery = async (
|
||||
}`
|
||||
);
|
||||
}
|
||||
|
||||
try {
|
||||
return cb ? cb(response) : response;
|
||||
} catch {}
|
||||
};
|
||||
Reference in new issue
Block a user