---
schema_version: "1"
id: 7993d8ac0c4d9e106b3ffe422371d59aa18c228fd4af37350c9522094287660c
title: TemplateInterruptException Apex Example
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/analytics/bi_dev_guide_wave_templates/guides/reference/bi-templatesdev-apex-class-error-examples2.md
canonical_url: https://developer.salesforce.com/docs/analytics/bi-dev-guide-wave-templates/guide/bi-templatesdev-apex-class-error-examples2.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 820f587f9d1cc7c8fa26997771d62b8093e2b626cfe69533831074ec4caa3b2d
products:
  - Analytics Templates Developer Guide
  - analytics
---

# 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:

```nolang
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.');
 }
}
```
