X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=common%2FclitkCommon.h;fp=common%2FclitkCommon.h;h=51258e66fc3abd5c418dfc480bdba43debd32442;hb=0451c66d4a069d04db99c9d719e053c6019923d8;hp=31f28dc40637bd95e91dfec7974f23183edd43ac;hpb=0d8fa5142465b40d3796e4347f8411fcbe374d4a;p=clitk.git diff --git a/common/clitkCommon.h b/common/clitkCommon.h index 31f28dc..51258e6 100644 --- a/common/clitkCommon.h +++ b/common/clitkCommon.h @@ -48,6 +48,24 @@ namespace clitk { typedef unsigned char uchar; typedef unsigned short ushort; typedef unsigned int uint; + +#define CLITK_TRY_CATCH_EXIT(func) \ + try { \ + func; \ + } \ + catch (const itk::ExceptionObject& e) { \ + e.Print(std::cout); \ + exit(-1);\ + } \ + catch (const std::exception& e) { \ + std::cout << e.what() << std::endl; \ + exit(-2);\ + } \ + catch (...) { \ + std::cout << "Unknown excpetion" << std::endl; \ + exit(-3); \ + } + //-------------------------------------------------------------------- // when everything goes wrong