-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Translation-specific errors should not crash the service #316
Comments
I thought wasm at least was living in |
That is a good point: https://emscripten.org/docs/optimizing/Optimizing-Code.html#c-exceptions In that case implementing this is a bit more more complicated, since things like the HTML class need to be altered a bit have a separate parse method that can somehow report error messages. Things like model loading also reference ABORT_IF. Not sure how we should handle that. Preferably also in a recoverable way (no need to crash the whole service if one model failed to load, right?). Then, how do we report the error? Some sort of rust-like If possible, I'd prefer to still keep exceptions working as is for the Python and C++ consumers of bergamot-translator. At least, in the places where exceptions make sense. We need something different for AsyncService anyway. |
Some of the |
Now low priority. This works fine in the production C++ API as is, and isn't blocking a WASM prototype. |
To be clear, this was only meant to return an error in WASM when provided ill-formed HTML by the extension. The extension should never do that because it must use text mode for |
From the last call:
I proposed to add an
ok
bool to response, similar tofetch()
's API: https://developer.mozilla.org/en-US/docs/Web/API/Response/okI tried something like this, e.g.:
But implementing it in such a way that exceptions get caught and their
what()
gets put into the correctresponse.error
, especially around the constructor ofHTML
, is a bit more complicated. All methods that interact with theresponse
objects now need to check whether it is valid by checking itsok()
.Alternative names:
good()
(e.g.iostream::good()
)operator bool()
of course, but you can't translate that 1-to-1 to JavascriptThe text was updated successfully, but these errors were encountered: