How can i replace the tag which is missing member with other string?

Hello,Team

When I build report, some data sources/members may not exist,I want to replace the error tag with some other strings (like ‘Not Found’),how can i do it?

For example,

String templateFilePath =...;
Document doc = new Document(templateFilePath);
ReportingEngine reportingEngine = new ReportingEngine();
try {
    reportingEngine.buildReport(doc, new HashMap<>());
} catch (Exception e) {
    //todo if e is MissingMemberException, replace the tag
}

Doc1.docx (12.0 KB)

@Doraemon There is no way to replace missed tags with custom text, but you can instruct Aspose.Words to ignore missed members. In this case Aspose.Words does not throw an exception and replaces tag with an empty string. Please see our documentation for more information:
https://docs.aspose.com/words/java/accessing-missing-members-of-data-objects/

@alexey.noskov
I got it. But our clients need more readable error message. The report engine‘s missing-member-error message is for developer rather than for client.In our application, missing-member-error is client-error,we need return more readable error message to clients.

@Doraemon
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): WORDSNET-26749

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

For now you can consider using syntax like this <<[value ?? "missing"]>>.

@alexey.noskov
Thanks for your support. The ticket is wonderful!

If my syntax like <<[Foramtters.format(vars)]>> or <<foreach [item in itemList]>>,how can i use ?? ?

@Doraemon Unfortunately, the proposed syntax is only applicable only for value placeholder.

Thanks for your reply. I will try it

1 Like