swisscom / cleanerversion

CleanerVersion adds a versioning/historizing layer to your relational DB which implements a "Slowly Changing Dimensions Type 2" behavior
Apache License 2.0
136 stars 53 forks source link

Exception message verbosity for <model>.DoesNotExist exception #116

Open maennel opened 8 years ago

maennel commented 8 years ago

Exception message verbosity for related (and failed) lookups could be enhanced by adding the source object's type, identity and, if set, the querytime used for the lookup. Note that the DoesNotExist class is bound to the related model's class. So, the following code would raise an Article.DoesNotExist exception if no article is found:

class Journal(Versionable):
   name = CharField(...)

class Article(Versionable):
   name = CharField(...)
   journal = VersionedForeignKey(Journal)

# ...some code happens here...

# Assume there's no current journal assigned to article, this would raise a Journal.DoesNotExist exception saying: "DoesNotExist: Journal matching query does not exist."
journal = article.journal