Skip to content
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

There is no way to property deal with exceptions in CoreViewer #1268

Open
depth42 opened this issue Feb 9, 2024 · 4 comments
Open

There is no way to property deal with exceptions in CoreViewer #1268

depth42 opened this issue Feb 9, 2024 · 4 comments
Labels

Comments

@depth42
Copy link

depth42 commented Feb 9, 2024

I am using the CoreViewer.loadDocument API for loading documents and I use the addListener API to get notified when loading has finished. When because of any reason Vivliostyle is throwing an exception during pagination, there is no way for me to detect this, as Vivliostyle simply catches and logs the exception but the listener is not notified.

@depth42 depth42 added the bug label Feb 9, 2024
@MurakamiShinyu
Copy link
Member

Vivliostyle Viewer can display error messages. The relevant code is found in:

this.coreViewer.addListener("error", (payload) => {
logger.error(payload.content);
});

error(content: unknown): void {

getDisplayMessage(errorInfo: ErrorInfo): string {

You may write similar code in your program that uses the CoreViewer. e.g.,

  coreViewer.addListener("error", (payload) => {
    alert(payload.content.error);
  });

@depth42
Copy link
Author

depth42 commented Feb 19, 2024

Thank you. Is it guaranteed, that Vivliostyle stops pagination with the first error that occurs? Or can there be more than one error?

@MurakamiShinyu
Copy link
Member

MurakamiShinyu commented Feb 19, 2024

There can be more than one error. However, "error" indicates something unexpected, e.g., "TypeError: Cannot read properties of undefined" is caused by program bugs and after such an exception occurs, normal processing is not expected to continue.

On the other hand, "warn" (you can use .addListener("warn", …)) indicates something wrong such as invalid or unsupported syntax in style sheets, and processing can continue.

@MurakamiShinyu
Copy link
Member

Thanks to this issue, I realized that the error handling in vivliostyle, especially on vivliostyle-print, needs to be improved, so I made the following pull requests:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants