Closed feral-dot-io closed 3 years ago
The problem is it's worse than you think: the handler gets called in an environment with no useful stacktrace. So if I don't handle it, basically no-one does. So an exception would either get lost or break your entire application (depending on exactly what platform you're running on).
Sorry for the super-slow response times.
Any exceptions thrown inside the handler function of
ajax-request
get caught by a catch-all and don't bubble up.This has resulted in bugs going unnoticed or at least, has made them harder to track down. If code in my handler fires an exception it goes unnoticed. I do a lot of work in the handler because I'm in the middle of callback hell.
Here is an example that demonstrates the problem. Running under Java / Emacs I don't see an error report just "Result ..." in the REPL.
I presume
ajax-request
has a catch all to ensure that:handler
is always called. This makes a lot of sense. It doesn't make as much sense to cover the user fn though as there's no further mechanism to propagate errors.