TemplateInterruptException Apex Example

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

note: Throwing an exception fails the app creation process.

Report an error to the user with a TemplateInterruptException:

public override void beforeAppCreate(wavetemplate.WaveTemplateInfo template. wavetemplate.Answers answers)
{
 // Validate that an answer is present and has a value.
 String includeCasesAnswer = (String)answers.get('IncludeCases');
 if (includeCasesAnswer.isEmpty() || includeCasesAnswer == null) {
  // Report issue to user
  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.');
 }
}