Skip to content

Commit 2510e0e

Browse files
author
Simon Milfred
committed
feat: added onError hook
1 parent 4052d55 commit 2510e0e

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

composables/useLimboSearch.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@ export const useLimboSearch = async (options = {}) => {
113113

114114
// Hooks
115115
onInit: () => {}, // { function } Hook for when the search is initiated. The reactive Limbo search object is passed as the first argument.
116+
onError: (error) => {
117+
throw error;
118+
}, // { function } Hook for when an error occurs in a fetch. The error object is passed as the first argument.
116119
onAfterSearch: () => {}, // { function } Hook for when the search is completed. The reactive Limbo search object is passed as the first argument and the state as the second argument.
117120
};
118121

@@ -679,7 +682,11 @@ export const useLimboSearch = async (options = {}) => {
679682
}).catch((error) => {
680683
// Throw as abort error
681684
if (!currentRequestController?.signal?.aborted) {
682-
throw error;
685+
if (compConfig.value.onAfterSearch) {
686+
compConfig.value.onError(error);
687+
} else {
688+
throw error;
689+
}
683690
}
684691
});
685692

0 commit comments

Comments
 (0)