ClassicUPS icon indicating copy to clipboard operation
ClassicUPS copied to clipboard

Need a good way to detect invalid tracking codes

Open mw44118 opened this issue 10 years ago • 2 comments

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?

mw44118 avatar Sep 08 '14 17:09 mw44118

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?

poundifdef avatar Sep 14 '14 02:09 poundifdef

I would either make a custom exception class, or explicitly return None.

mw44118 avatar Oct 22 '14 18:10 mw44118