mirror of
https://github.com/darksaid98/oxmysql.git
synced 2026-12-02 14:38:50 +00:00
fix: error handling when using callbacks
Only allow manual error handling when using the await/sync methods, or when calling the default exports. Async/Callback returns need to throw errors for compatibility.
This commit is contained in:
1 parent
21e73c17b8
commit
bccd6a1035
3 files changed
+7
-6
No files matched your search
@@ -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) cb(null, error);
|
||||
if (throwError) throw new Error(error);
|
||||
if (cb && !throwError) cb(null, error);
|
||||
if (throwError || !cb) throw new Error(error);
|
||||
});
|
||||
};
|
||||
@@ -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) cb(null, error)
|
||||
if (throwError) throw new Error(error)
|
||||
if (cb && !throwError) cb(null, error);
|
||||
if (throwError || !cb) throw new Error(error);
|
||||
});
|
||||
};
|
||||
Reference in new issue
Block a user