Returning an error from data.src triggers exception
See original GitHub issueIn the official codepen playground and other places you have this code now:
src: async () => {
try {
return data;
} catch (error) {
return error;
}
}
But if this errors, autoComplete.js triggers an exception:
19:08:26.990 Uncaught (in promise) TypeError: data.store.forEach is not a function
findMatches dataController.js:36
default index.f58c4ea9.js:22807
run eventController.js:27
timer io.js:89
setTimeout handler*debounce/< io.js:89
input eventController.js:41
addEvents eventController.js:71
eventsManager eventController.js:14
addEvents eventController.js:70
default index.f58c4ea9.js:22471
autoComplete autoComplete.js:37
init index.f58c4ea9.js:1261
Because in start.js or findMatches
you never validate that it didn’t error.
Also on a sidenote, I don’t think cache
is working at the moment (though I believe the cache should be removed anyway), because you never set data.cache
anywhere:
$ pwd
/home/folk/.../node_modules/@tarekraafat/autocomplete.js/src
$ rg '.cache'
services/init.js
48: if (data.cache) await getData(ctx);
controllers/dataController.js
12: if (data.cache && data.store) return;
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Errors function in Power Apps - Power Platform
Errors can happen when a record of a data source is changed. Many causes are possible, including network outages, inadequate permissions, ...
Read more >jQuery Ajax error handling, show custom exception ...
Custom exception ModelStateException that gets thrown when validation fails on the server (model state reports validation errors when we use data annotations ...
Read more >8. Errors and Exceptions — Python 3.11.1 documentation
When an exception is created in order to be raised, it is usually initialized with information that describes the error that has occurred....
Read more >Error handling and automatic retries in AWS Lambda
When you invoke a function, two types of error can occur. Invocation errors occur when the invocation request is rejected before your function...
Read more >Exceptions and debugging - Advanced R. - Hadley Wickham
This reruns the command that created the error, pausing execution where the error occurred. You're now in an interactive state inside the function,...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Also https://github.com/TarekRaafat/autoComplete.js/blob/7e1930626ae8cc9a8ac90fd3aac4fdf31202866b/src/autoComplete.js#L38 is wrong. I had not tried it when I wrote that, it should say something like “Makes the Tab key select the entry navigated to using the keyboard, just like Enter.”
config.data.filter
should perhaps say “Used to filter and sort matching returns from config.data.src before showing them to the user. Signature: (Array), is given all the results from config.data.src that matches the query.”I think I misunderstand your last comment. I’m not really able to parse and understand what you said 😛
Anyway it could be as simple as changing start.js from
to
I realise it looks dirty. Also I’ve not tested it, and start.js needs to import
open
from listController. And if I was going to implement it “properly” I’d move this logic to listController, probably adding areset
function there for resetting .cursor and .innerHTML and so forth.Anyway again I don’t really understand your previous comment so if this comment is useless please excuse me. I do understand that the error is in
feedback
anddata.store
, but not the sentence before that - this one: