Skip to content
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

handle errors without proper stacks #58

Merged
merged 1 commit into from Mar 13, 2016

Conversation

@cjihrig
Copy link
Contributor

cjihrig commented Mar 11, 2016

Closes #57

@cjihrig cjihrig added the bug label Mar 11, 2016
@cjihrig cjihrig added this to the 2.1.1 milestone Mar 11, 2016
const at = internals.at(this._ref);

if (at !== undefined) {
original.at = internals.at(this._ref);

This comment has been minimized.

Copy link
@geek

geek Mar 13, 2016

Member

should this be

original.at = at;

This comment has been minimized.

Copy link
@cjihrig

cjihrig Mar 13, 2016

Author Contributor

Yes

@@ -432,12 +436,14 @@ internals.type = function (value) {
internals.at = function (error) {

error = error || new Error();
const at = error.stack.replace(error.toString(), '').split('\n').slice(1).filter(internals.filterLocal)[0].match(/^\s*at \(?(.+)\:(\d+)\:(\d+)\)?$/);
return {
const stack = typeof error.stack === 'string' ? error.stack : '';

This comment has been minimized.

Copy link
@geek

geek Mar 13, 2016

Member

could be

const stack = error.stack || '';

This comment has been minimized.

Copy link
@cjihrig

cjihrig Mar 13, 2016

Author Contributor

Right. I'd rather ensure that we have a string though. Someone could create a new Error object and set the stack to something else. This will help keep code from breaking down if they do something stupid.

This comment has been minimized.

Copy link
@geek

geek Mar 13, 2016

Member

sounds good

@cjihrig cjihrig force-pushed the cjihrig:stacks branch from 66965f6 to ebee954 Mar 13, 2016
@cjihrig

This comment has been minimized.

Copy link
Contributor Author

cjihrig commented Mar 13, 2016

Thanks for the review

cjihrig added a commit that referenced this pull request Mar 13, 2016
handle errors without proper stacks
@cjihrig cjihrig merged commit 5228d5e into hapijs:master Mar 13, 2016
1 check passed
1 check passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@cjihrig cjihrig deleted the cjihrig:stacks branch Mar 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.