Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Express.js Example

Blake Niemyjski edited this pageDec 12, 2016 ·2 revisions

Exceptionless Express.js Example for the JavaScript / Node.js Client

Add Exceptionless to your Express.js project and start collecting unhandled errors and 404s quickly.

To start, just add the following middleware to the bottom of your middleware definitions.

// This middleware processes any unhandled errors that may occur in your middleware.app.use(function(err,req,res,next){client.createUnhandledException(err,'express').addRequestInfo(req).submit();res.status(500).send('Something broke!');});// This middleware processes 404’s.app.use(function(req,res,next){client.createNotFound(req.originalUrl).addRequestInfo(req).submit();res.status(404).send('Sorry cant find that!');});

Sample Express.js App

We have built a quickExpress.js sample app you can play around with.

Run the sample app by following the steps below:

  1. InstallNode.js
  2. Clone or download our repository from GitHub.
  3. Runnpm install. This steps is required because we reference the exceptionless package from the root dist folder.
  4. Navigate to theexample\express folder via the command line (e.g., cd example\express)
  5. Runnpm install
  6. Open app.js in your favorite text editor and set theapiKey.
  7. Run node app.js.
  8. Navigate tohttp://localhost:3000 in your browser to view the express app.
  9. To create an error, navigate tohttp://localhost:3000/boom

Troubleshooting

We recommend enabling debug logging by callingclient.config.useDebugLogger();. This will output messages to the console regarding what the client is doing. Please contact us by creating an issue on GitHub if you need assistance or have any feedback for the project.

Not What You're Looking For?

Looking forGeneral Exceptionless Documentation,UI Documentation, orDocumentation for another Client?

Visit the Primary Exceptionless Documentation Page and go from there.

Clone this wiki locally


[8]ページ先頭

©2009-2025 Movatter.jp