ClassicUPS
ClassicUPS copied to clipboard
Need a good way to detect invalid tracking codes
I'm using your package to check if packages have been delivered. The tracking codes I get are manually entered and sometimes they are entered with errors.
What's the right way to check if a tracking code is valid?
Right now, if you enter an invalid tracking number, you'll get a KeyError
exception when invoking tracking_info.delivered
because the XML returned doesn't have the expected tags.
However, I realize that this is cumbersome. Do you have any thoughts on how to make this better?
I would either make a custom exception class, or explicitly return None.