quarkusio/quarkus · error · TemplateException

${exception}

Error message

${exception}

What it means

CompletedStage.get() (Qute) rethrows the exception the stage was completed with. If it is already a TemplateException it is thrown as-is; any other exception is wrapped in a TemplateException. Message is the original exception's message, so `${exception}` reflects the underlying error.

Source

Thrown at independent-projects/qute/core/src/main/java/io/quarkus/qute/CompletedStage.java:68

    private final T result;
    private final Throwable exception;

    private CompletedStage(T result, Throwable exception) {
        this.result = result;
        this.exception = exception;
    }

    public boolean isFailure() {
        return exception != null;
    }

    public T get() {
        if (exception != null) {
            if (exception instanceof TemplateException te) {
                throw te;
            }
            // Always wrap the original exception if completed exceptionally
            throw new TemplateException(exception);
        }
        return result;
    }

    @Override
    public <U> CompletionStage<U> thenApply(Function<? super T, ? extends U> fn) {
        Objects.requireNonNull(fn);
        if (exception == null) {
            final U u;
            try {
                u = fn.apply(this.result);
            } catch (Throwable e) {
                return new CompletedStage<>(null, e);
            }
            return new CompletedStage<>(u, null);
        }
        return new CompletedStage<>(null, exception);
    }

View on GitHub (pinned to e1c734241f)

Solutions

  1. Read the wrapped cause chain — fix the original template/expression error it reports
  2. Fix the template expression referenced by the cause (missing property, wrong method name)
  3. Register a value resolver or add the missing property/method to the data model
  4. In custom code, prefer toCompleteStage()/join with proper error handling rather than raw get()

Example fix

// before
Object v = completedStage.get(); // throws TemplateException wrapping cause
// after
try {
    Object v = completedStage.get();
} catch (TemplateException e) {
    logger.error("Qute evaluation failed", e.getCause());
}
Defensive patterns

Strategy: try-catch

Validate before calling

if (stage.isCompletedExceptionally()) {
    // inspect cause before get()
    stage.exceptionally(t -> { log.error("Qute eval failed", t); return null; });
}

Try / catch

try {
    T value = completedStage.get();
} catch (TemplateException e) {
    Throwable cause = e.getCause(); // fix the original template error
}

Prevention

When it happens

Trigger: Calling get() on a CompletedStage completed exceptionally, typically when a Qute expression evaluation fails (missing property, resolver error) and the engine materializes the result synchronously.

Common situations: Template rendering errors surfacing during evaluation: nonexistent bean properties, failed method invocations, or errors thrown inside value resolvers; also seen when blocking on results in tests or custom extensions.

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/3940859e6bae9249. Report an issue: GitHub.