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

use_die_instead_exit #2

Merged
merged 4 commits into from
Jul 15, 2019
Merged

use_die_instead_exit #2

merged 4 commits into from
Jul 15, 2019

Conversation

regcostajr
Copy link
Contributor

@whindsx
Copy link
Owner

whindsx commented Jul 11, 2019

Thanks for the PR. Seems reasonable and I'd like to include it.

However the die at Line 86 seems to just get skipped over (the others work):
$info = $btc->getaddressinfo("12312");
It's weird it just skips right over that and continues execution.

Did you test it and it work for you? I'm using Perl 5.20.2, I doubt it matters.

Any idea why this might now work? Some funny business with LWP::UserAgent?
https://github.com/regcostajr/Bitcoin-RPC-Client/blob/a4a851d37ab96a83d8992e398fc6a1574ebd5d14/lib/Bitcoin/RPC/Client.pm#L86

@regcostajr
Copy link
Contributor Author

regcostajr commented Jul 12, 2019

@whindsx, yes you are right, the die seems to have no behavior inside the handler, but I'm wondering if this handler is really needed since we have this error handling here too:

if ($res->is_error) {

We should die after the error is confirmed right? so should be fine to die at this point and remove the handler totally, I will update the PR.

@whindsx
Copy link
Owner

whindsx commented Jul 12, 2019

We should leave the \n in the die statements, as it prevents the line number from being added to the error line. What went wrong is irrelevant to where it went wrong in Client.pm. The output should be as close as possible to what bitcoind produces IMO.

error code: -5, error message: Invalid address (getaddressinfo) at /btc/regcostajr/Bitcoin-RPC-Client/lib/Bitcoin/RPC/Client.pm line 95.

error code: -5, error message: Invalid address (getaddressinfo)

https://perldoc.perl.org/functions/die.html
If the string exception does not end in a newline, the current script line number and input line number (if any) and a newline are appended to it.

@whindsx whindsx merged commit 3b9bdd7 into whindsx:master Jul 15, 2019
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.

2 participants