mirror of
https://github.com/darksaid98/oxmysql.git
synced 2026-12-01 14:38:50 +00:00
fix(logger): potential error on error handling
This commit is contained in:
1 parent
0ede55d66c
commit
0f5c044050
1 file changed
+9
-6
+9
-6
@@ -7,26 +7,29 @@ export function logError(
|
||||
invokingResource: string,
|
||||
cb: CFXCallback | undefined,
|
||||
isPromise: boolean | undefined,
|
||||
err: any,
|
||||
err: Error | string = '',
|
||||
query?: string,
|
||||
parameters?: CFXParameters,
|
||||
includeParameters?: boolean
|
||||
) {
|
||||
const message = `${invokingResource} was unable to execute a query!${query ? `\n${`Query: ${query}`}` : ''}${
|
||||
const message =
|
||||
typeof err === 'object' ? err.message : err.replace(/SCRIPT ERROR: citizen:[\w\/\.]+:\d+[:\s]+/, '');
|
||||
|
||||
const output = `${invokingResource} was unable to execute a query!${query ? `\n${`Query: ${query}`}` : ''}${
|
||||
includeParameters ? `\n${JSON.stringify(parameters)}` : ''
|
||||
}\n${err.message || (err as string).replace(/SCRIPT ERROR: citizen:[\w\/\.]+:\d+[:\s]+/, '')}`;
|
||||
}\n${message}`;
|
||||
|
||||
TriggerEvent('oxmysql:error', {
|
||||
query: query,
|
||||
parameters: parameters,
|
||||
message: err.message,
|
||||
message: message,
|
||||
err: err,
|
||||
resource: invokingResource,
|
||||
});
|
||||
|
||||
if (cb && isPromise) return cb(null, message);
|
||||
if (cb && isPromise) return cb(null, output);
|
||||
|
||||
console.error(message);
|
||||
console.error(output);
|
||||
}
|
||||
|
||||
export const profilerStatements = [
|
||||
|
||||
Reference in new issue
Block a user