How to use @google-cloud/error-reporting - 8 common examples

To help you get started, we’ve selected a few @google-cloud/error-reporting examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github googleapis / nodejs-error-reporting / samples / implicitSetup.js View on Github external
function setupImplicit() {
  // [START error_reporting_setup_implicit]
  // [START error_reporting_setup_nodejs_implicit]
  // Imports the Google Cloud client library
  const {ErrorReporting} = require('@google-cloud/error-reporting');

  // Instantiates a client
  const errors = new ErrorReporting();

  // Reports a simple error
  errors.report('Something broke!');
  // [END error_reporting_setup_nodejs_implicit]
  // [END error_reporting_setup_implicit]
}
github googleapis / nodejs-error-reporting / samples / manual.js View on Github external
function manual() {
  // [START error_reporting_manual]
  // [START error_reporting_setup_nodejs_manual]
  // Imports the Google Cloud client library
  const {ErrorReporting} = require('@google-cloud/error-reporting');

  // Instantiates a client
  const errors = new ErrorReporting();

  // Use the error message builder to customize all fields ...
  const errorEvent = errors.event();

  // Add error information
  errorEvent.setMessage('My error message');
  errorEvent.setUser('root@nexus');

  // Report the error event
  errors.report(errorEvent, () => {
    console.log('Done reporting error event!');
  });

  // Report an Error object
  errors.report(new Error('My error message'), () => {
    console.log('Done reporting Error object!');
github googleapis / nodejs-error-reporting / samples / snippets.js View on Github external
function setupExplicit() {
  // [START error_reporting_setup_explicit]
  // [START error_reporting_setup_nodejs_explicit]
  // Imports the Google Cloud client library
  const ErrorReporting = require('@google-cloud/error-reporting')
    .ErrorReporting;

  // On Node 6+ the following syntax can be used instead:
  // const {ErrorReporting} = require('@google-cloud/error-reporting');

  // With ES6 style imports via TypeScript or Babel, the following
  // syntax can be used instead:
  // import {ErrorReporting} from '@google-cloud/error-reporting';

  // Instantiates a client
  const errors = new ErrorReporting({
    projectId: 'your-project-id',
    keyFilename: '/path/to/key.json',
  });

  // Reports a simple error
  errors.report('Something broke!');
  // [END error_reporting_setup_nodejs_explicit]
  // [END error_reporting_setup_explicit]
}
github googleapis / nodejs-error-reporting / samples / explicitSetup.js View on Github external
function explicitSetup() {
  // [START error_reporting_setup_explicit]
  // [START error_reporting_setup_nodejs_explicit]
  // Imports the Google Cloud client library
  const {ErrorReporting} = require('@google-cloud/error-reporting');

  // Instantiates a client
  const errors = new ErrorReporting({
    projectId: 'your-project-id',
    keyFilename: '/path/to/key.json',
  });

  // Reports a simple error
  errors.report('Something broke!');
  // [END error_reporting_setup_nodejs_explicit]
  // [END error_reporting_setup_explicit]
}
github GoogleCloudPlatform / training-data-analyst / courses / developingapps / nodejs / stackdriver-debug-errorreporting / end / quiz-app / app.js View on Github external
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

'use strict';
require('@google-cloud/debug-agent').start({ allowExpressions: true });
const ErrorReporting = require(
       '@google-cloud/error-reporting').ErrorReporting;

const path = require('path');
const express = require('express');
const config = require('./config');

const errorReporting = new ErrorReporting();
const app = express();

// Static files
app.use(express.static('public/'));

app.disable('etag');
app.set('views', path.join(__dirname, 'web-app/views'));
app.set('view engine', 'pug');
app.set('trust proxy', true);
app.set('json spaces', 2);

// Questions
app.use('/questions', require('./web-app/questions'));

// Quizzes API
app.use('/api/quizzes', require('./api'));
github googleapis / nodejs-error-reporting / samples / quickstart.js View on Github external
function quickstart() {
  // [START error_reporting_quickstart]
  // Imports the Google Cloud client library
  const {ErrorReporting} = require('@google-cloud/error-reporting');

  // Instantiates a client
  const errors = new ErrorReporting();

  // Reports a simple error
  errors.report('Something broke!');
  // [END error_reporting_quickstart]
}
quickstart();
github googleapis / nodejs-error-reporting / samples / snippets.js View on Github external
// [START error_reporting_setup_nodejs_express]
  const express = require('express');

  // Imports the Google Cloud client library
  const ErrorReporting = require('@google-cloud/error-reporting')
    .ErrorReporting;

  // On Node 6+ the following syntax can be used instead:
  // const {ErrorReporting} = require('@google-cloud/error-reporting');

  // With ES6 style imports via TypeScript or Babel, the following
  // syntax can be used instead:
  // import {ErrorReporting} from '@google-cloud/error-reporting';

  // Instantiates a client
  const errors = new ErrorReporting();

  const app = express();

  app.get('/error', (req, res, next) => {
    res.send('Something broke!');
    next(new Error('Custom error message'));
  });

  app.get('/exception', () => {
    JSON.parse('{"malformedJson": true');
  });

  // Note that express error handling middleware should be attached after all
  // the other routes and use() calls. See the Express.js docs.
  app.use(errors.express);
github GoogleCloudPlatform / training-data-analyst / courses / developingapps / v1.2 / nodejs / stackdriver-trace-monitoring / end / frontend / app.js View on Github external
projectId: config.get('GCLOUD_PROJECT')
});

// END TODO

require('@google-cloud/debug-agent').start({
  allowExpressions: true,
  projectId: config.get('GCLOUD_PROJECT')
});

const path = require('path');
const express = require('express');
const scores = require('./gcp/spanner');

const {ErrorReporting} = require('@google-cloud/error-reporting');
const errorReporting = new ErrorReporting({
  projectId: config.get('GCLOUD_PROJECT')
});

const app = express();

// Static files
app.use(express.static('frontend/public/'));

app.disable('etag');
app.set('views', path.join(__dirname, 'web-app/views'));
app.set('view engine', 'pug');
app.set('trust proxy', true);
app.set('json spaces', 2);

// Questions
app.use('/questions', require('./web-app/questions'));

@google-cloud/error-reporting

Error Reporting Client Library for Node.js

Apache-2.0
Latest version published 1 year ago

Package Health Score

70 / 100
Full package analysis

Popular @google-cloud/error-reporting functions

Similar packages