-
Notifications
You must be signed in to change notification settings - Fork 604
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
error-reporting: Fix report()
silently failing
#2363
error-reporting: Fix report()
silently failing
#2363
Conversation
@@ -4,7 +4,7 @@ | |||
"main": "./src/index.js", | |||
"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.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
There was a problem hiding this 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.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
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.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
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.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
* @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.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
* @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.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
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.
28226ff
to
3df370b
Compare
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.
@stephenplusplus This is ready to land. |
If the
report()
method is called with a number, an associatederror never appears in the error reporting console, and no log
message is printed to the user to indicate why the error has not
appeared.