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

Fix Error object creation resulting in failing blockchain tests #197

Merged
merged 2 commits into from
Sep 8, 2017
Merged

Fix Error object creation resulting in failing blockchain tests #197

merged 2 commits into from
Sep 8, 2017

Conversation

holgerd77
Copy link
Member

No description provided.

@@ -177,7 +177,7 @@ module.exports = function (opts, cb) {
error: err
Copy link
Member

Choose a reason for hiding this comment

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

Is this field expected to be an Error object or text?

Copy link
Member Author

Choose a reason for hiding this comment

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

I just stayed in the semantics of the change with the new Error object introduced before.

Tested in CL, this works if an Error object is provided, but it uses just the error description from the first error and not the string. Is this acceptable? I'm not so deep into error handling...

@@ -177,7 +177,7 @@ module.exports = function (opts, cb) {
error: err
}

afterBlock(cb.bind(this, new Error(err), result))
afterBlock(cb.bind(this, err, result))
Copy link
Member

Choose a reason for hiding this comment

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

Is the input err to this method (parseBlockResults) always an Error instance?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think this was changed in the last weeks on many places to always use an Error object and not a plain string, wasn't it? Not sure though if this was a concerted effort to change this on all places.

It's probably nevertheless not a good solution to start with checks like

if (typeof(err) === 'string') {
  err = new Error(err)
}

at this place.

Copy link
Contributor

Choose a reason for hiding this comment

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

The Error/string types seem compatible in node and the browser, so I guess this is fine.

Copy link
Member

Choose a reason for hiding this comment

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

@holgerd77 I meant that this function receives err and only sets it to an Error in certain places, but there are no safeguards in place that the incoming err is an instance of Error.

@cdetrio
Copy link
Contributor

cdetrio commented Sep 8, 2017

The invalid block error was being swallowed, so I added a line to log it. Any reason not to log it to the console?

@holgerd77 holgerd77 merged commit 9d81b50 into ethereumjs:master Sep 8, 2017
@axic
Copy link
Member

axic commented Sep 8, 2017

Any reason not to log it to the console?

Since this is a library it is not supposed to log to the console :)

holgerd77 added a commit that referenced this pull request Mar 11, 2021
toBuffer now throws if strings aren't 0x-prefixed hex values
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.

4 participants