N4S4 / synology-api

A Python wrapper around Synology API
MIT License
360 stars 137 forks source link

Custom exceptions. #122

Closed pnearing closed 1 year ago

pnearing commented 1 year ago

I've added the code to catch and raise our own exceptions, as well as moved auth error codes into it's own variable. I've updated _get_error_message to reflect this. I created a variable in auth.py called USE_EXCEPTIONS, by default this is set to True, but to have the code revert to it's previous behaviour, all you need to do is set this to False.

N4S4 commented 1 year ago

That is cool! thanks, however the code contains many typos and most of the returns have some issue, many functions may return string or dict, setting return type to dict[str, object] leads to synology_api.exceptions.FileStationError in many cases maybe better to return any or add | str what do you think to remove __init__variables typing to avoid unnecessary errors what IDE are you using?

pnearing commented 1 year ago

Hey, NP. I use vscode on ubuntu. What IDE do you use? What does it use for python checking? vscode uses pyLance. If functions return string or dict, I should have caught that when doing the typing, and I'm sorry for that, I can go back over and check. I don't catch any typo's in my IDE either, so I'm not sure there. I also don't understand how setting the return type changes the exception that's thrown. I didn't test it specifically against FileStation though. Since all my code passes my IDE, and I'm guessing it fails yours, maybe I can install yours in my system and check with that.