Skip to content

Commit d70186f

Browse files
authored
fix: remove unused error concepts function snippets (#3669)
* fix: remove unused error concepts function snippets * fix: cleaning up lint * fix: moving region tag to not include the ending } * fix: more linting issues
1 parent 9c17a7f commit d70186f

File tree

2 files changed

+0
-61
lines changed

2 files changed

+0
-61
lines changed

functions/helloworld/helloError/index.js

-40
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414

1515
'use strict';
1616

17-
const functions = require('@google-cloud/functions-framework');
18-
1917
/* eslint-disable no-unused-vars */
2018

2119
/**
@@ -32,41 +30,3 @@ exports.helloError = (event, context, callback) => {
3230
throw new Error('I failed you'); // Will cause a cold start if not caught
3331
// [END functions_helloworld_error]
3432
};
35-
36-
/**
37-
* Background Cloud Function that throws a value.
38-
*
39-
* @param {object} event The Cloud Functions event.
40-
* @param {object} context The event metadata.
41-
* @param {function} callback The callback function.
42-
*/
43-
exports.helloError2 = (event, context, callback) => {
44-
// [START functions_helloworld_error_2]
45-
// These WILL be reported to Error Reporting
46-
console.error(new Error('I failed you')); // Logging an Error object
47-
console.error('I failed you'); // Logging something other than an Error object
48-
throw 1; // Throwing something other than an Error object
49-
// [END functions_helloworld_error_2]
50-
};
51-
52-
/**
53-
* Background Cloud Function that returns an error.
54-
*
55-
* @param {object} event The Cloud Functions event.
56-
* @param {object} context The event metadata.
57-
* @param {function} callback The callback function.
58-
*/
59-
exports.helloError3 = (event, context, callback) => {
60-
// [START functions_helloworld_error_3]
61-
// This will NOT be reported to Error Reporting
62-
callback('I failed you');
63-
// [END functions_helloworld_error_3]
64-
};
65-
66-
// HTTP Cloud Function that returns an error.
67-
functions.http('helloError4', (req, res) => {
68-
// [START functions_helloworld_error_4]
69-
// This will NOT be reported to Error Reporting
70-
res.status(500).send('I failed you');
71-
// [END functions_helloworld_error_4]
72-
});

functions/helloworld/helloError/test/index.test.js

-21
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
// limitations under the License.
1414

1515
const assert = require('assert');
16-
const sinon = require('sinon');
17-
1816
const program = require('..');
1917

2018
describe('index.test.js', () => {
@@ -25,23 +23,4 @@ describe('index.test.js', () => {
2523
});
2624
});
2725
});
28-
29-
describe('functions_helloworld_error_2', () => {
30-
describe('Error handling (unit tests)', () => {
31-
it('helloError2: should throw a value', () => {
32-
assert.throws(program.helloError2, '1');
33-
});
34-
});
35-
});
36-
37-
describe('functions_helloworld_error_3', () => {
38-
describe('Error handling (unit tests)', () => {
39-
it('helloError3: callback should return an errback value', () => {
40-
const cb = sinon.stub();
41-
program.helloError3(null, null, cb);
42-
assert.ok(cb.calledOnce);
43-
assert.ok(cb.calledWith('I failed you'));
44-
});
45-
});
46-
});
4726
});

0 commit comments

Comments
 (0)