X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=common%2FclitkCommon.h;h=8f9ce0f0ee20fb8ad45b48f38876fc3d993695c5;hb=0405727a0d0d5955b4b623a9c4bc60622a85fdd5;hp=97808d8d870ba778887a8ba98542cd3ea7ddf8b5;hpb=da7742b2188d694446ffedc1835b778fb71849b7;p=clitk.git diff --git a/common/clitkCommon.h b/common/clitkCommon.h index 97808d8..8f9ce0f 100644 --- a/common/clitkCommon.h +++ b/common/clitkCommon.h @@ -38,8 +38,9 @@ #if defined(unix) || defined(__APPLE__) # include # include -#elif defined(WIN32) +#elif defined(_WIN32) # include +# include #endif //-------------------------------------------------------------------- @@ -48,6 +49,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