Closed microbit-sam closed 4 years ago
Have you been able to replicate the original issue? Or do you know the type of the object that gets to this point?
Basically we are getting something that is not an Error
object, and I think we need to understand what that is and why that happens, as this might be a symptom of a different problem.
No I've not managed to discover that yet, almost all of the calls to webusbErrorHandler
are from .catch()
events so should have them
The only call that isn't from a catch()
is
var error = {"name": "device-disconnected", "message": config["translate"]["webusb"]["err"]["device-disconnected"]};
webusbErrorHandler(error);
I'm checking translations now, but I would have thought message
would still have been defined even if there was a missing translation
That sounds like a good candidate as the original issue was found when the editor was in Spanish.
If so, shall I move the check to:
var error = {"name": "device-disconnected", "message": (config["translate"]["webusb"]["err"]["device-disconnected"] ? config["translate"]["webusb"]["err"]["device-disconnected"] : "missing-translation" };
webusbErrorHandler(error);
Actually I've just realised, the metrics will have seperate URLs for errors in different languages.. that's not ideal
I think we need a better way to deal with missing translations. Likely to create a "getter" that returns the english version if the string is not found.
I think we need a better way to deal with missing translations. Likely to create a "getter" that returns the english version if the string is not found.
Yep that sounds like a good idea
Saw this error again while testing PR #270:
So it looks like it's not related to the translations after all.
Interesting, do you still have that window open? I think errors should be logged when webusbErrorHandler is called
I've restructured webusbErrorHandler, and it feels better to me, but you may have other thoughts Carlos!
replace()
should always be called on a string nowError: Bad response for 140 -> 5
to the console, and replaced the user facing text with a generic WebUSB Error
Check that
err.message
exists before using itMay not be necessary, updated translation handling can probably remove the possibility of this happening