EnterpriseyIntranet / nextcloud-API

NextCloud OCS API for Python
GNU General Public License v3.0
27 stars 27 forks source link

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

Open simfr24 opened 5 years ago

simfr24 commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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 :)