Permalink
Browse files

Fix zone2{sql,json} exit codes

To be consistent with general practice, fix zone2{sql,json} to exit
with:
 * 0 on success
 * 1 on error

This also moves the catch block after the last line of main, so a
"theoretically" possible exception in ::arg().mustDo would get caught.
(Also, one level less of indent!)
  • Loading branch information...
1 parent 7593c40 commit 7538e56294da1a3c658f59cef3923ec6d8995480 @zeha zeha committed with mind04 Aug 28, 2013
Showing with 27 additions and 32 deletions.
  1. +14 −16 pdns/backends/bind/zone2json.cc
  2. +13 −16 pdns/backends/bind/zone2sql.cc
@@ -122,10 +122,10 @@ ArgvMap &arg()
int main(int argc, char **argv)
+try
{
vector<string> lines;
- try {
reportAllTypes();
reportFancyTypes();
#if __GNUC__ >= 3
@@ -232,21 +232,19 @@ int main(int argc, char **argv)
num_domainsdone=1;
}
cerr<<num_domainsdone<<" domains were fully parsed, containing "<<g_numRecords<<" records\n";
+
+ return 0;
- }
- catch(AhuException &ae) {
- cerr<<"\nFatal error: "<<ae.reason<<endl;
- return 0;
- }
- catch(std::exception &e) {
- cerr<<"died because of STL error: "<<e.what()<<endl;
- exit(0);
- }
- catch(...) {
- cerr<<"died because of unknown exception"<<endl;
- exit(0);
- }
-
+}
+catch(AhuException &ae) {
+ cerr<<"\nFatal error: "<<ae.reason<<endl;
+ return 1;
+}
+catch(std::exception &e) {
+ cerr<<"\ndied because of STL error: "<<e.what()<<endl;
+ return 1;
+}
+catch(...) {
+ cerr<<"\ndied because of unknown exception"<<endl;
return 1;
-
}
@@ -241,8 +241,8 @@ ArgvMap &arg()
int main(int argc, char **argv)
+try
{
- try {
reportAllTypes();
reportFancyTypes();
#if __GNUC__ >= 3
@@ -379,26 +379,23 @@ int main(int argc, char **argv)
}
cerr<<num_domainsdone<<" domains were fully parsed, containing "<<g_numRecords<<" records\n";
- }
- catch(AhuException &ae) {
- cerr<<"\nFatal error: "<<ae.reason<<endl;
- return 0;
- }
- catch(std::exception &e) {
- cerr<<"died because of STL error: "<<e.what()<<endl;
- exit(0);
- }
- catch(...) {
- cerr<<"died because of unknown exception"<<endl;
- exit(0);
- }
-
if(::arg().mustDo("transactions") && g_intransaction) {
if(g_mode != SQLITE)
cout<<"COMMIT WORK;"<<endl;
else
cout<<"COMMIT;"<<endl;
}
+ return 0;
+}
+catch(AhuException &ae) {
+ cerr<<"\nFatal error: "<<ae.reason<<endl;
+ return 1;
+}
+catch(std::exception &e) {
+ cerr<<"\ndied because of STL error: "<<e.what()<<endl;
+ return 1;
+}
+catch(...) {
+ cerr<<"\ndied because of unknown exception"<<endl;
return 1;
-
}

0 comments on commit 7538e56

Please sign in to comment.