Search in sources :

Example 1 with SoyFutureException

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)");
    }
}
Also used : SoyTofuException(com.google.template.soy.tofu.SoyTofuException) SoyDict(com.google.template.soy.data.SoyDict) SoyFutureException(com.google.template.soy.data.SoyFutureException) SoyTofuException(com.google.template.soy.tofu.SoyTofuException) SoyFutureException(com.google.template.soy.data.SoyFutureException) Test(org.junit.Test)

Example 2 with SoyFutureException

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)");
    }
}
Also used : SoyTofuException(com.google.template.soy.tofu.SoyTofuException) SoyDict(com.google.template.soy.data.SoyDict) SoyFutureException(com.google.template.soy.data.SoyFutureException) SoyTofuException(com.google.template.soy.tofu.SoyTofuException) SoyFutureException(com.google.template.soy.data.SoyFutureException) Test(org.junit.Test)

Aggregations

SoyDict (com.google.template.soy.data.SoyDict)2 SoyFutureException (com.google.template.soy.data.SoyFutureException)2 SoyTofuException (com.google.template.soy.tofu.SoyTofuException)2 Test (org.junit.Test)2