Skip to content

Omit the stack trace for user errors.#7480

Merged
jridgewell merged 1 commit intoampproject:masterfrom
cvializ:cv-trim-stack
Feb 21, 2017
Merged

Omit the stack trace for user errors.#7480
jridgewell merged 1 commit intoampproject:masterfrom
cvializ:cv-trim-stack

Conversation

@cvializ
Copy link
Copy Markdown
Contributor

@cvializ cvializ commented Feb 10, 2017

  • The stack trace is not important for user errors
  • This should improve performance since accessing the stack trace is expensive

Implements #4949

src/error.js Outdated
}
}

const messageIsUserErrorMessage = isUserErrorMessage(message);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: isUserError.

Copy link
Copy Markdown
Contributor

@jridgewell jridgewell left a comment

Choose a reason for hiding this comment

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

Whoops, need to update tests.

@cvializ
Copy link
Copy Markdown
Contributor Author

cvializ commented Feb 13, 2017

Thanks for catching that! PTAL

@jridgewell
Copy link
Copy Markdown
Contributor

Still no tests...

@cvializ
Copy link
Copy Markdown
Contributor Author

cvializ commented Feb 15, 2017

Oh thanks I see, I've added tests to specifically verify user errors exclude the stack. PTAL

});

it('should omit the error stack for user errors', () => {
const log = new Log(window, () => LogLevel.FINE, USER_ERROR_SENTINEL);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The loggers may already be installed?

it('should omit the error stack for user errors', () => {
const log = new Log(window, () => LogLevel.FINE, USER_ERROR_SENTINEL);
try {
log.assert(false, '123');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

log.createError('123');. That'll allow you to get rid of the try-catch.

getErrorReportUrl(undefined, undefined, undefined, undefined, e,
true));
const query = parseQueryString(url.search);
expect(query.s).to.not.equal(e.stack);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Unnecessary because of the following expect.

@cvializ
Copy link
Copy Markdown
Contributor Author

cvializ commented Feb 15, 2017

Oh nice, thanks. This looks much cleaner

import {parseUrl, parseQueryString} from '../../src/url';
import {user} from '../../src/log';
import {
Log,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Cleanup these imports.

@cvializ
Copy link
Copy Markdown
Contributor Author

cvializ commented Feb 21, 2017

I don't have authorization to merge to master at this time. If we want this merged, someone other than me will have to pull the trigger.

@jridgewell jridgewell merged commit f552646 into ampproject:master Feb 21, 2017
mrjoro pushed a commit to mrjoro/amphtml that referenced this pull request Apr 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants