How to check if a module/template is defined?

Thanks!

I check for some stuff before the app is “ready” and set an error if one of these checks fails. Later in error route I check if there’s a specific template for this error and if there is, I render the error-specific template, otherwise I’m rendering a generic template with “there was an error” message.