Raise KeyError instead of generic Exception

This is a more specific exception that allows better catch.

issue6409
review34891002
This commit is contained in:
Cédric Krier
2017-04-01 10:38:51 +02:00
parent a908e8cc74
commit 62826903c2
+1 -1
View File
@@ -1079,7 +1079,7 @@ class ModelData(ModelSQL, ModelView):
('fs_id', '=', fs_id),
], limit=1)
if not data:
raise Exception("Reference to %s not found"
raise KeyError("Reference to %s not found"
% ".".join([module, fs_id]))
id_ = cls.read([d.id for d in data], ['db_id'])[0]['db_id']
cls._get_id_cache.set(key, id_)