X-Git-Url: http://erislabs.net/gitweb/?p=mir.git;a=blobdiff_plain;f=source%2Fmir%2Fmodule%2FAbstractModule.java;h=d65dd2b331c920ad328463e71549c709a002dda0;hp=cfd11a7a216e7e52ae4ee66b6232fb989d208547;hb=42680c1f9fe3250bcbd0f9ed5d9dee6188333b15;hpb=d3e3f0ffeefd8692277d9a82af477a64ae85e118 diff --git a/source/mir/module/AbstractModule.java b/source/mir/module/AbstractModule.java index cfd11a7a..d65dd2b3 100755 --- a/source/mir/module/AbstractModule.java +++ b/source/mir/module/AbstractModule.java @@ -31,6 +31,7 @@ package mir.module; import mir.entity.Entity; import mir.entity.EntityList; import mir.storage.Database; +import mir.storage.DatabaseExc; import java.util.Map; @@ -60,19 +61,23 @@ public class AbstractModule { return database; } - public Entity getById (String id) throws ModuleExc, ModuleFailure { - try { - if (database == null) - throw new ModuleExc("AbstractModule.getById: No Database set!"); - Entity entity = database.selectById(id); + public Entity getById (String anId) throws ModuleFailure, EntityNotFoundExc { + if (database == null) { + throw new ModuleFailure("AbstractModule.getById: No Database set!"); + } - if (entity == null) - throw new ModuleExc("AbstractModule.getById: No object for id = " + id); - return entity; - } - catch (Throwable e) { - throw new ModuleFailure(e); - } + try { + Entity result = database.selectById(anId); + + if (result == null) { + throw new EntityNotFoundExc("AbstractModule.getById: No object for id = " + anId); + } + + return result; + } + catch (DatabaseExc e) { + throw new ModuleFailure("Database exception while retrieving entity with id " + anId); + } } public EntityList getByWhereClause (String whereClause, int offset) throws ModuleExc, ModuleFailure {