```javascript app.use( supertokens.errorHandler(...
# general
m
Copy code
javascript
app.use(
  supertokens.errorHandler({
    onUnauthorised: (err, req, res, next) => {
      if (process.env.NODE_ENV === 'development') {
        console.log(err)
      }
      res.status(401).json({
        msg: 'Please login again'
      })
    },
    onTryRefreshToken: (err, req, res, next) => {
      if (process.env.NODE_ENV === 'development') {
        console.log(err)
      }
      res.status(440).json({
        msg: 'Call the refresh API'
      })
    },
    onTokenTheftDetected: async (sessionHandle, userId, req, res, next) => {
      res.status(401).json({
        msg: 'You are being attacked'
      })
      await supertokens.revokeSession(sessionHandle)
    }
  })
)
app.use((err, req, res, next) => {
  handleError.handleError(res, err)
})