-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
Preserve error types during translation #11834
Preserve error types during translation #11834
Conversation
ae8522c
to
7ce370b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seem like way too much code/complexity for an edge-case, and in a previous PR (see #11689) the consensus was that if this should be fixed then simply re-throwing the original exception would be preferable.
Ok, if the possible change of the original exception outside of pdf.js is acceptable, I can just rethrow the exception with the translated message, without any cloning 😄 |
7ce370b
to
d614534
Compare
I've pushed the updated, simplified version which rethrows the original exception. |
By preserving the exception type, more fine-grained error handling can be performed via client-side logic (e.g. redirect to a search page if a PDF is not found, or to a ticket system in case of invalid PDF files). The original exception is now re-thrown. Fixes mozilla#11658
d614534
to
f5fd24a
Compare
/botio-linux preview |
From: Bot.io (Linux m4)ReceivedCommand cmd_preview from @timvandermeij received. Current queue size: 0 Live output at: http://54.67.70.0:8877/4ab244e9adc073f/output.txt |
From: Bot.io (Linux m4)SuccessFull output at http://54.67.70.0:8877/4ab244e9adc073f/output.txt Total script time: 3.34 mins Published |
Let's do this. Thank you for your contribution! |
Great 👍 You're welcome. Thanks for the feedback and the quick and professional handling. |
By preserving the exception type, more fine-grained error handling can be performed via client-side logic (e.g. redirect to a search page if a PDF is not found, or to a ticket system in case of invalid PDF files).
The original exception type and its properties (e.g. status code) are preserved by cloning the error object and assigning the translated message. Note that only a shallow clone is performed for simplicity.
Fixes #11658