Skip to content

Conversation

@DominicKramer
Copy link
Contributor

If the report() method is called with a number, an associated
error never appears in the error reporting console, and no log
message is printed to the user to indicate why the error has not
appeared.

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Jun 6, 2017
"repository": "GoogleCloudPlatform/google-cloud-node",
"scripts": {
"test": "nyc --exclude=\"fuzzer.js\" mocha ./test/unit/**/*.js",
"test": "nyc --exclude=\"fuzzer.js\" mocha ./test/unit/*.js ./test/unit/**/*.js",

This comment was marked as spam.

This comment was marked as spam.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 99.988% when pulling 0b34534 on DominicKramer:bug/reporting-non-errors-silently-fails into 03c276d on GoogleCloudPlatform:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 99.988% when pulling 93a897c on DominicKramer:bug/reporting-non-errors-silently-fails into 03c276d on GoogleCloudPlatform:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 99.988% when pulling 10807f1 on DominicKramer:bug/reporting-non-errors-silently-fails into 03c276d on GoogleCloudPlatform:master.

@DominicKramer DominicKramer requested a review from ofrobots June 7, 2017 17:04
@coveralls
Copy link

Coverage Status

Coverage remained the same at 99.988% when pulling 2e6b422 on DominicKramer:bug/reporting-non-errors-silently-fails into 03c276d on GoogleCloudPlatform:master.

Copy link
Contributor

@ofrobots ofrobots left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some comments. Some of them were present in the original code, so it might be acceptable to do them in a follow-on (ie. keep this as a refactor, and make logical changes in a follow-on).

* Constructs a string representation of the stack trace at the point where
* this function was invoked. Note that the stack trace will not include any
* references to this function itself.
* @function buildStackTrace

This comment was marked as spam.

This comment was marked as spam.

var fauxError = new Error('');
var fullStack = fauxError.stack.split('\n');
var cleanedStack = fullStack.slice(2).join('\n');
var cleanedStack = buildStackTrace('', 1);

This comment was marked as spam.

This comment was marked as spam.

function populateErrorMessage(ob, em) {
if (ob === null || ob === undefined) {
populateFromUnknown(ob, em);
} else if (ob instanceof Error) {

This comment was marked as spam.

This comment was marked as spam.

* @returns {Undefined} - does not return anything
*/
function populateFromNumber(num, errorMessage) {
var message = isNumber(num) && isFunction(num.toString) ? num.toString() : '';

This comment was marked as spam.

This comment was marked as spam.

* @returns {Undefined} - does not return anything
*/
function populateFromString(str, errorMessage) {
errorMessage.setMessage(buildStackTrace(str, 3));

This comment was marked as spam.

This comment was marked as spam.

If the `report()` method is called with a number, an associated
error never appears in the error reporting console, and no log
message is printed to the user to indicate why the error has not
appeared.
The `Error.captureStackTrace` method is now used in the
`buildStackTrace` function to create a stack trace.
The code for verifiying that stack traces don't contain
error-reporting specific frames has been consolidated into a
single location.
@DominicKramer DominicKramer force-pushed the bug/reporting-non-errors-silently-fails branch from 28226ff to 3df370b Compare June 15, 2017 18:36
@coveralls
Copy link

Coverage Status

Coverage remained the same at 99.988% when pulling 3df370b on DominicKramer:bug/reporting-non-errors-silently-fails into 06e743e on GoogleCloudPlatform:master.

In particular, the `buildStackTrace` was updated to ensure that
no error-reporting specific frames are included in the built
stack trace.  In addition, the system-tests have been updated to
ensure error-reporting related frames, and only those frames, are
removed from the built stack trace.
@coveralls
Copy link

Coverage Status

Coverage remained the same at 99.988% when pulling 24fbc3b on DominicKramer:bug/reporting-non-errors-silently-fails into 06e743e on GoogleCloudPlatform:master.

@DominicKramer
Copy link
Contributor Author

@stephenplusplus This is ready to land.

@stephenplusplus stephenplusplus merged commit 02afcef into googleapis:master Jun 15, 2017
GautamSharda pushed a commit that referenced this pull request Jan 14, 2026
* error-reporting: Fix `report()` silently failing

If the `report()` method is called with a number, an associated
error never appears in the error reporting console, and no log
message is printed to the user to indicate why the error has not
appeared.

* Fix linting errors

* Add the new `build-stack-trace.js` file

* Add more system tests for `errors.report()`

* Rename errorHandlerRouter to populateErrorMessage

* Rename error-router to populate-error-message

* Reorganize the populate-error-message tests

* Update buildStackTrace to use captureStackTrace

The `Error.captureStackTrace` method is now used in the
`buildStackTrace` function to create a stack trace.

* Simplify the system tests

The code for verifiying that stack traces don't contain
error-reporting specific frames has been consolidated into a
single location.

* Consolidate code in populate-error-message.js

* Make the `buildStackTrace` more robust

In particular, the `buildStackTrace` was updated to ensure that
no error-reporting specific frames are included in the built
stack trace.  In addition, the system-tests have been updated to
ensure error-reporting related frames, and only those frames, are
removed from the built stack trace.
GautamSharda pushed a commit that referenced this pull request Jan 15, 2026
* error-reporting: Fix `report()` silently failing

If the `report()` method is called with a number, an associated
error never appears in the error reporting console, and no log
message is printed to the user to indicate why the error has not
appeared.

* Fix linting errors

* Add the new `build-stack-trace.js` file

* Add more system tests for `errors.report()`

* Rename errorHandlerRouter to populateErrorMessage

* Rename error-router to populate-error-message

* Reorganize the populate-error-message tests

* Update buildStackTrace to use captureStackTrace

The `Error.captureStackTrace` method is now used in the
`buildStackTrace` function to create a stack trace.

* Simplify the system tests

The code for verifiying that stack traces don't contain
error-reporting specific frames has been consolidated into a
single location.

* Consolidate code in populate-error-message.js

* Make the `buildStackTrace` more robust

In particular, the `buildStackTrace` was updated to ensure that
no error-reporting specific frames are included in the built
stack trace.  In addition, the system-tests have been updated to
ensure error-reporting related frames, and only those frames, are
removed from the built stack trace.
GautamSharda pushed a commit that referenced this pull request Feb 5, 2026
* error-reporting: Fix `report()` silently failing

If the `report()` method is called with a number, an associated
error never appears in the error reporting console, and no log
message is printed to the user to indicate why the error has not
appeared.

* Fix linting errors

* Add the new `build-stack-trace.js` file

* Add more system tests for `errors.report()`

* Rename errorHandlerRouter to populateErrorMessage

* Rename error-router to populate-error-message

* Reorganize the populate-error-message tests

* Update buildStackTrace to use captureStackTrace

The `Error.captureStackTrace` method is now used in the
`buildStackTrace` function to create a stack trace.

* Simplify the system tests

The code for verifiying that stack traces don't contain
error-reporting specific frames has been consolidated into a
single location.

* Consolidate code in populate-error-message.js

* Make the `buildStackTrace` more robust

In particular, the `buildStackTrace` was updated to ensure that
no error-reporting specific frames are included in the built
stack trace.  In addition, the system-tests have been updated to
ensure error-reporting related frames, and only those frames, are
removed from the built stack trace.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: error-reporting cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants