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:
Linden committed 2022-06-17 21:40:27 +10:00
1 parent 21e73c17b8
commit bccd6a1035
3 files changed
+7 -6

No files matched your search

+2 -2
View File
@@ -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);
});
};