poundifdef / ClassicUPS

Wrapper around the UPS API for creating shipping labels and fetching a package's tracking status.
Other
58 stars 36 forks source link

Need a good way to detect invalid tracking codes #6

Open mw44118 opened 10 years ago

mw44118 commented 10 years ago

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?

poundifdef commented 10 years ago

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?

mw44118 commented 9 years ago

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