TemplateInterruptException Apex Example

Use the TemplateInterruptException class to handle template runtime errors cleanly and provide clear information to template users.

Throwing an exception fails the app creation process.

Note

Report an error to the user with a TemplateInterruptException: 

1public override void beforeAppCreate(wavetemplate.WaveTemplateInfo template. wavetemplate.Answers answers)
2{
3 // Validate that an answer is present and has a value.
4 String includeCasesAnswer = (String)answers.get('IncludeCases');
5 if (includeCasesAnswer.isEmpty() || includeCasesAnswer == null) {
6  // Report issue to user
7  throw new TemplateInterruptException('You didn't answer "yes" to the question that asked if you use Cases. Go back to the wizard and answer this question.');
8 }
9}