The 'Populate Word Document' engine provides a configuration option named 'Population Options' which controls the behaviour of the engine. This configuration option is set to 'Default' by default.
If an error occurs during execution an exception is raised and reported:
The details of the actual error are contained within the body of the output, i.e. the information returned by the Encodian action, see below:
The error in this example states:
"A general error occurred populating the word document provided: An error has been encountered at the end of expression 'companyName>>\rFormed: '. Can not get the value of member 'Formed' on type 'System.Data.DataRow'."
The error message is stating there is an issue processing the companyName token, for this example an invalid token configuration was passed to generate the error:
Optimizing Error Handling - Solution Building
Whilst building your solution we recommend changing the Population Options' configuration option to 'InlineErrors', this instructs the population error not to throw an exception but to add the error message to the output document:
Upon processing the same request as the previous example, the flow execution will complete successfully:
On this occasion the error is added to the document itself:
On first view, the error looks to be incorrectly placed, but it is positioned where the error occurred and because the token was not closed correctly the exception was thrown on detection of the next token.
This approach to error handling can help speed up the development process.
Optimizing Error Handling - Disable Retries
Alternatively, you can also simply disable Flow's default retry policy which will automatically execute the same request 4 times before an error is thrown, see below:
This configuration will ensure that your flow execution will fail much more quickly, allowing you to validate any errors via the errors collection returned by the Encodian action.
Execution time with the standard retry policy: Above 1 minute
Execution time with the standard retry policy disabled: 4 seconds