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

101
Visualizações
Express is not handling errors for function

I'm using a function for multiple times by calling from different routes. It's running but express/node.js not handling errors in the function.

Here's the example.

# routes.js
var app = express()
var { test } = require('../functions/test.js')(app)

router.get('/test', (req, res) => {
  console.log(test())
})
# test.js
function test() {
  return 'Hey'
}

module.exports = function(app){
  return { test }
}

If I call a function in test() which is not exists, It's not throwing errors and returns nothing inside console.log(test())

# test.js
function test() {
  heyHeyheyHey()
  return 'Hey'
}

module.exports = function(app){
  return { test }
}

Do I have to define this module in somewhere or something?

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

0

I ran a quick demo and the error has been thrown. I'm sure you've figured it out but here is my snippet. enter image description here

enter image description here

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