From 71e9281823cc905c8885cf8a998a669d55726acf Mon Sep 17 00:00:00 2001 From: Jon Bergli Heier Date: Sat, 22 Mar 2014 14:06:28 +0100 Subject: tracking: Handle unknown types in track_status. --- modules/tracking.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'modules') diff --git a/modules/tracking.py b/modules/tracking.py index 90b3555..8083182 100644 --- a/modules/tracking.py +++ b/modules/tracking.py @@ -79,6 +79,7 @@ class Package(Base): class PackageError(Exception): pass class NoPackageFound(PackageError): pass +class UnknownTypeError(PackageError): pass class TrackingResult: def __init__(self, code, date, desc, delivered = False, previous_code = None): @@ -250,6 +251,9 @@ def code_split(code): def get_tracking_module(arg): type, code = code_split(arg) + if not type in tracking_modules: + raise UnknownTypeError('Unknown type "%s"' % type) + return tracking_modules[type]() class Module: @@ -627,3 +631,5 @@ if __name__ == '__main__': print '\n'.join(track) else: print track + +# vim: noet ts=4 -- cgit v1.2.3