Closed jchwenger closed 2 months ago
Hi @jchwenger, thank you for bringing this up!
We have decided to move from gotResults(error, results)
to gotResults(result, error)
in the new version. We believe this interface is a little more intuitive for beginners since they can choose to ignore the error
parameter.
That being said, error handling was never consistently implemented in both the v0 and v1 versions of the library. The error
parameter will always be undefined
on a lot of the callback functions. We should definitely look into it hooking up the error
parameter soon.
For now, you could try:
function gotResult(results, error) {
if (error) {
// handle error
}
// Do something with results
}
This should be compatible with the current version (v1.0.2) and will start to fully work once we update the error handling in the library.
Let us know if you have any thoughts or suggestions!
Hi @ziyuan-linn,
Thanks for the quick reply, that makes complete sense! I also fully approve the choice, I also think it's more intuitive this way 🙌 !
I have been using ml5 for projects and teaching and I am eager to see the new version evolve. Is it better here, for question, or on the discord? Thanks!
Here or discord works! Feel free to use the one you prefer.
Hi lovely ml5 people!
Very glad to see the new release! I'm in the process of updating a series of examples and a question springs to mind (not a bug, really): previously, many examples using callbacks to handle predictions would follow the following syntax:
This has now been reduced to only
gotResult(results)
, I wondered why, and what would be your recommendation for error handling in the new framework (perhaps you included that within the model methods directly)?I'm unsure, to be honest, if that's an ml5 question proper, or more like a JS pattern one, so apologies if this question isn't in the right place!