use of com.google.template.soy.data.SoyFutureException in project closure-templates by google.
the class TofuExceptionsTest method testExceptions_transclusion_failedFuture.
@Test
public void testExceptions_transclusion_failedFuture() {
Exception futureFailureCause = new Exception("boom");
SoyDict data = SoyValueConverterUtility.newDict("foo", immediateFailedFuture(futureFailureCause));
try {
tofu.newRenderer("ns.transclusionCaller").setData(data).render();
fail();
} catch (SoyTofuException ste) {
SoyFutureException sfe = (SoyFutureException) ste.getCause();
assertThat(sfe).hasMessageThat().isEqualTo("Error dereferencing future");
assertThat(sfe).hasCauseThat().isEqualTo(futureFailureCause);
assertThat(ste).hasMessageThat().isEqualTo("When evaluating \"$content\": When evaluating \"$foo\": Error dereferencing future");
assertThat(ste.getStackTrace()[0].toString()).isEqualTo("ns.transclusionCaller(no-path:17)");
assertThat(ste.getStackTrace()[1].toString()).isEqualTo("ns.transclusionCallee(no-path:23)");
assertThat(ste.getStackTrace()[2].toString()).isEqualTo("ns.transclusionCaller(no-path:16)");
}
}
use of com.google.template.soy.data.SoyFutureException in project closure-templates by google.
the class TofuExceptionsTest method testExceptions_failedFuture.
@Test
public void testExceptions_failedFuture() {
Exception futureFailureCause = new Exception("boom");
SoyDict data = SoyValueConverterUtility.newDict("foo", immediateFailedFuture(futureFailureCause));
// This error occurs due to a failed future.
try {
tofu.newRenderer("ns.callerTemplate").setData(data).render();
fail();
} catch (SoyTofuException ste) {
assertThat(ste).hasMessageThat().isEqualTo("When evaluating \"$foo.boo\": Error dereferencing future");
SoyFutureException sfe = (SoyFutureException) ste.getCause();
assertThat(sfe).hasMessageThat().isEqualTo("Error dereferencing future");
assertThat(sfe).hasCauseThat().isEqualTo(futureFailureCause);
assertThat(ste.getStackTrace()[0].toString()).isEqualTo("ns.calleeTemplate(no-path:10)");
assertThat(ste.getStackTrace()[1].toString()).isEqualTo("ns.callerTemplate(no-path:5)");
}
}
Aggregations