From: Arvin Schnell Date: Wed, 20 Apr 2011 14:34:17 +0000 (+0200) Subject: - use exceptions instead of assert X-Git-Tag: v0.1.3~407 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=23f54f972f979497e2ceef70b34c68bb88024a28;p=thirdparty%2Fsnapper.git - use exceptions instead of assert --- diff --git a/snapper/Factory.cc b/snapper/Factory.cc index 42e0c331..6947659a 100644 --- a/snapper/Factory.cc +++ b/snapper/Factory.cc @@ -20,10 +20,10 @@ */ -#include "assert.h" #include "auto_ptr.h" #include "snapper/Snapper.h" +#include "snapper/Exception.h" namespace snapper @@ -35,7 +35,9 @@ namespace snapper Snapper* createSnapper(const string& config_name) { - assert(!the_one.get()); + if (the_one.get()) + throw LogicErrorException(); + the_one.reset(new Snapper(config_name)); return the_one.get(); } @@ -44,8 +46,9 @@ namespace snapper void deleteSnapper(Snapper* s) { - assert(the_one.get()); - assert(s == the_one.get()); + if (!the_one.get() || s != the_one.get()) + throw LogicErrorException(); + the_one.reset(); }