-
-
Notifications
You must be signed in to change notification settings - Fork 573
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
Error handling in break_time #2074
Conversation
Hello @swapsha96! Thanks for updating the PR.
Comment last updated on April 12, 2017 at 11:33 Hours UTC |
Thank you @pep8speaks ! I removed unnecessary blank lines. Is it now good to go? |
Why is it not OK to have parse_time raise the error?
…On Wed, Apr 12, 2017 at 7:34 AM, Swapnil Sharma ***@***.***> wrote:
Thank you @pep8speaks <https://github.com/pep8speaks> ! I removed
unnecessary blank lines. Is it now good to go?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#2074 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AA8CF-l70PykrVQYj2tjutFFcqZ6z3YHks5rvLbjgaJpZM4M7SPY>
.
|
@wafels Generally, error handling using try-catch from user side is discouraged. User is supposed handle value returned from a function. Errors like ValueError, NameError, SyntaxError can lead to application crash and thus, function must return appropriate error and user can handle it using if-else condition. |
Ok, I get it. So in this case, None is returned?
Hmmm. This might be an example of something that could be implemented
across sunpy, if we make that decision.
…On Wed, Apr 12, 2017 at 1:41 PM, Swapnil Sharma ***@***.***> wrote:
@wafels <https://github.com/wafels> Generally, error handling using
try-catch from user side is discouraged. User is supposed handle value
returned from a function. Errors like ValueError, NameError, SyntaxError
can lead to application crash and thus, function must return appropriate
error and user can handle it using if-else condition.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#2074 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AA8CF7iQWfCcTvFnHquGQkUEbc-aOk-4ks5rvQy-gaJpZM4M7SPY>
.
|
@wafels Is this PR alright to be merged? I am ready to find and fix such errors. |
I don't know about this PR or the other places in the code where the
approach in this PR might be needed. I think this is a coding practices
decision that we could choose to enforce across sunpy.
…On Wed, Apr 12, 2017 at 2:38 PM, Swapnil Sharma ***@***.***> wrote:
@wafels <https://github.com/wafels> Is this PR alright to be merged? I am
ready to find and fix such errors.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#2074 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AA8CF3jtmigc_0-dR2mBedgFZRA5d6Kpks5rvRoygaJpZM4M7SPY>
.
|
I don't agree to fail quietly and return |
I don't like this PR. Not raising exceptions means that:
Also, returning If this is in fact will be the preferred coding style, presumably we should change |
As a side note, can someone remind me why this function is called |
Following code returns ValueError and is not handled properly:
from sunpy.time import break_time
break_time('garbage')
Following result is obtained on the terminal:
This PR uses try-catch to handle the error input in break_time() function.
pass
is used as it is used in line 186 of same file.