Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

144
Visualizações
Why does nunjucks fail silently on bad syntax while compiling, or bad data while rendering?

While editing my templates, if I make a mistake, say for example I leave off a closing tag, as in...

{% if variable %}
  Notice there is no closing tag within this template!

When compiling this, nunjucks seems to remain silent. I don't see an exception or console.log. Is this the intended experience? Is there a config flag to turn on "die loudly if anything is wrong"?

The same applies during rendering. If my template is fine, but I render it with data that does not match, it seems to silently fail. Is it supposed to fail quietly, not throw any exceptions, not log to the console?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

It's all my fault. Nunjucks does throw exceptions for this sort of thing. The exception was being lost because of how I was using the jQuery promises library. The source explains it very nicely...

// Support: Promises/A+ section 2.3.3.3.4.1
// https://promisesaplus.com/#point-61
// Ignore post-resolution exceptions
if ( depth + 1 >= maxDepth ) {

The idea is, if the .then() handler of a promise throws an exception, the promises library catches that exception. The promise's .fail() handler is then called. If the promise doesn't have a fail handler, that's when the exception is "lost". By using promises, I bought in to the error handling story of promises.

It wasn't nunjucks' fault.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda