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

How to catch the error when is_ok is False ? #32

Open
simfr24 opened this issue Mar 8, 2019 · 2 comments
Open

How to catch the error when is_ok is False ? #32

simfr24 opened this issue Mar 8, 2019 · 2 comments

Comments

@simfr24
Copy link

simfr24 commented Mar 8, 2019

I try to upload a file (88MB in my example) with this code :

if nxc.upload_file("username", image_file, dir_path+'/'+image_file).is_ok:
       print("success")
else: 
       print("fail") 

And the upload fails, how can I catch what the problem is ?

@matejak
Copy link

matejak commented Mar 13, 2019

This is a bit cumbersome ATM, you can save the result into a variable and use the status_code attribute. The response has a full_data attribute, so you can inspect that one for clues.

Would you rather appreciate an exception raised on failure that would translate to a useful feedback message?

@simfr24
Copy link
Author

simfr24 commented Mar 13, 2019

Thank you, the .data attribute got the info.
However if you want to add a .error attribute that would get the error without having to parse it manually, it would be nice.

As far as my project is concerned, the upload is a workaround because the move does not work ( see issue #33 ) so I would choose to focus on this instead of the upload :)

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

No branches or pull requests

2 participants