Skip to content

Conversation

@zakarialounes
Copy link
Contributor

For easy debugging.

public static fromString(str: string): Uint32 {
if (!str.match(/^[0-9]+$/)) {
throw new Error("Invalid string format");
throw new Error("Invalid string format. Found: " + str);
Copy link
Contributor

@webmaster128 webmaster128 Oct 29, 2022

Choose a reason for hiding this comment

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

Can you put the values in quotes? This makes it easier to find begin and end in the error messages and allows debugging empty string inputs.

Probably easier to write with a template string.

throw new Error(`Invalid string format. Found: '${str}'`);

Thanks

Copy link
Contributor Author

@zakarialounes zakarialounes Oct 29, 2022

Choose a reason for hiding this comment

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

I had also thought about it, but I based it on

throw new Error("Invalid value in byte. Found: " + bytes[i]);

I will adapt to reflect your suggestion.

private constructor(data: BN) {
if (data.isNeg()) {
throw new Error("Input is negative");
throw new Error("Input is negative. Found: " + data);
Copy link
Contributor

Choose a reason for hiding this comment

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

Does that give you a proper debug representation of a BN?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think so, I will adapt this with the call toString()

Copy link
Contributor

@webmaster128 webmaster128 left a comment

Choose a reason for hiding this comment

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

LGTM overall

@zakarialounes
Copy link
Contributor Author

Should be good @webmaster128

@zakarialounes
Copy link
Contributor Author

any news @webmaster128?

@dynst
Copy link
Contributor

dynst commented Jul 30, 2025

The integer classes recently got rewritten to use bigint so there are merge conflicts now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants