How to use the @google-cloud/common.ApiError function in @google-cloud/common

To help you get started, we’ve selected a few @google-cloud/common 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-spanner / test / database.ts View on Github external
it('should not auto create unless requested', done => {
      const error = new ApiError('Error.');
      error.code = 5;

      database.getMetadata = callback => {
        callback(error);
      };

      database.create = () => {
        throw new Error('Should not create.');
      };

      database.get(err => {
        assert.strictEqual(err, error);
        done();
      });
    });
github googleapis / nodejs-spanner / test / instance.ts View on Github external
it('should not auto create unless requested', done => {
      const error = new ApiError('Error.') as ServiceError;
      error.code = 5;

      sandbox
        .stub(instance, 'getMetadata')
        .callsFake(callback => callback!(error));

      instance.create = () => {
        throw new Error('Should not create.');
      };

      instance.get(err => {
        assert.strictEqual(err, error);
        done();
      });
    });