MCPcopy
hub / github.com/GoogleCloudPlatform/nodejs-docs-samples / express

Function express

error-reporting/express.js:22–53  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

20'use strict';
21
22function express() {
23 // [START error_reporting_setup_nodejs_express]
24 const express = require('express');
25
26 // Imports the Google Cloud client library
27 const {ErrorReporting} = require('@google-cloud/error-reporting');
28
29 // Instantiates a client
30 const errors = new ErrorReporting();
31
32 const app = express();
33
34 app.get('/error', (req, res, next) => {
35 res.send('Something broke!');
36 next(new Error('Custom error message'));
37 });
38
39 app.get('/exception', () => {
40 JSON.parse('{"malformedJson": true');
41 });
42
43 // Note that express error handling middleware should be attached after all
44 // the other routes and use() calls. See the Express.js docs.
45 app.use(errors.express);
46
47 const PORT = process.env.PORT || 8080;
48 app.listen(PORT, () => {
49 console.log(`App listening on port ${PORT}`);
50 console.log('Press Ctrl+C to quit.');
51 });
52 // [END error_reporting_setup_nodejs_express]
53}
54express();

Callers 15

server.jsFile · 0.85
index.jsFile · 0.85
app.jsFile · 0.85
app.jsFile · 0.85
getSampleFunction · 0.85
index.jsFile · 0.85
server.jsFile · 0.85
app.jsFile · 0.85
index.tsFile · 0.85
app.jsFile · 0.85
app.jsFile · 0.85
app.jsFile · 0.85

Calls 1

getMethod · 0.45

Tested by 2

getSampleFunction · 0.68
getSampleFunction · 0.68