Skip to content

How to get Sentry to log errors within try-catch #427

@Jedeu

Description

@Jedeu

Hi I'm seeing Sentry send uncaught errors but nothing found within a try-catch block. I read this earlier question and wanted to see if my setup might be preventing Sentry from sending the errors over. Thanks in advance!

server/index.js (entrypoint)

const Routers = require('./routers');
const config = require('./config');
app.use('baseUrl', Routers);
const nuxt = new Nuxt(config);
await nuxt.ready();

app.use(nuxt.render);

routers.js

  const router = require('express').Router();
  const MySpace = require('./services/MySpace');

  router.use('/my_space', MySpace);

MySpace.js

  async doTheThing(req, res) {
    try {
      // execute some logic
    } catch (e) {
      // process.sentry.captureException(e) <--- I need to manually add this if I want to send stuff to Sentry, hoping to send any errors over automatically
      return res.status(500).json(e);
    }
  }

  Router.post('/do_the_thing', doTheThing);

nuxt.config.js

sentry: {
    dsn: myDsn,
    tracing: true,
    config: {
      debug: true,
    },
},

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions